summaryrefslogtreecommitdiffstats
path: root/software/c.page
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2011-09-21 00:42:50 -0400
committerbnewbold <bnewbold@robocracy.org>2011-09-21 00:42:50 -0400
commit226b1e9aabc4a557cd522f4488d9e03492e367f0 (patch)
tree9725f4b4fc9fe08d046f4e9e2938d8b96b3acda5 /software/c.page
parent36492bceeec70927e4f20f03ce981852a3813174 (diff)
downloadknowledge-226b1e9aabc4a557cd522f4488d9e03492e367f0.tar.gz
knowledge-226b1e9aabc4a557cd522f4488d9e03492e367f0.zip
formatting fixes
Diffstat (limited to 'software/c.page')
-rw-r--r--software/c.page24
1 files changed, 12 insertions, 12 deletions
diff --git a/software/c.page b/software/c.page
index 910a5de..ec02db6 100644
--- a/software/c.page
+++ b/software/c.page
@@ -10,19 +10,19 @@ automagically. Eg, ``p+3`` -> ``0xFEFE0000 + 3 * (sizeof foo)``.
Examples of tricky pointer sytax::
- int *ip;
- (++*p)
- (*p++)
- ++(*p)
- *(++p)
+ int *ip;
+ (++*p)
+ (*p++)
+ ++(*p)
+ *(++p)
In the context of references like function declarations, only the size of the
first dimension of a multi-dimensional array is free; the others must be
specified explicitly::
- void copy_2d_array(int a[][10], int b[][10]); // Ok
- void copy_2d_array(int a[][], int b[][]); // Invalid
- void copy_2d_array(int a[10][], int b[10][]); // Invalid
+ void copy_2d_array(int a[][10], int b[][10]); // Ok
+ void copy_2d_array(int a[][], int b[][]); // Invalid
+ void copy_2d_array(int a[10][], int b[10][]); // Invalid
Negative indexing of arrays is "allowed" (reads ahead of the array in memory);
need to check for that case explicitly.
@@ -35,10 +35,10 @@ The "update statement" of a for loop gets executed at the /end/ of every loop,
which means an iteration variable gets updated once more than might be
expected::
- int i;
- for(i = 0; i < 10; i++) {
- }
- printf("%d\n", i); // prints 10, not 9
+ int i;
+ for(i = 0; i < 10; i++) {
+ }
+ printf("%d\n", i); // prints 10, not 9
Any 'inline' should probably be 'static' (local linkage).