summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-09-07 20:27:06 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-09-07 20:27:06 +0200
commit8f28988793600a9f64de89d87de6df8f2ba602ca (patch)
tree55f02a0427ecb7b2219556b38079a134ba673bf9
parent5bd0d783276dc08af7cc9fcd719c7f0d839a8fa8 (diff)
downloadstyleguide-8f28988793600a9f64de89d87de6df8f2ba602ca.tar.gz
styleguide-8f28988793600a9f64de89d87de6df8f2ba602ca.tar.xz
styleguide-8f28988793600a9f64de89d87de6df8f2ba602ca.zip
C-STYLE: *x vs x[0]
-rw-r--r--C-STYLE.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/C-STYLE.md b/C-STYLE.md
index e7921cd..7119800 100644
--- a/C-STYLE.md
+++ b/C-STYLE.md
@@ -112,10 +112,13 @@ but merely how to format it.
 
 * Initialize zeroed structs using `= { 0 }`.
 
-* Prefer `x+i` over `&x[i]`.
-
 * Prefer `i++` over `++i`.
 
+* Prefer `*x` over `x[0]`
+  (unless the same code also accesses `x[1]`, `x[2]` etc.)
+
+* Prefer `x+i` over `&x[i]`.
+
 * Do not use `NULL`.  Use `0` for null pointers.
   Remember to use `(char *)0` as a sentinel for execl(3).