diff options
author | Jakukyo Friel <weakish@gmail.com> | 2016-09-13 20:14:28 +0800 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-09-13 14:14:28 +0200 |
commit | c8fb84cc91f9d852f38bd961af974949ffcc82e5 (patch) | |
tree | 7c3f0b961f8ce4c3250115f388eb21db8370666a /c.html.markdown | |
parent | 161edb1f6e76a8451d2e74a8fb24d6874f7dab66 (diff) |
c: init array with string literals not introduced. (#2369)
* c: fix using pointer before introduced.
* c: init array with string literals not introduced.
To avoid using the concept pointer before it has been introduced,
previously it is changed to array.
But as @geoffliu pointed out,
array initialization using string literals is not introduced either.
So this commit uses neither pointer nor array.
Discussing `i++` and `++i` does not need to involve pointer or array.
* c: use `var = value` instead of `->`.
`->` is typically used for functions.
Thanks, @vendethiel.
Diffstat (limited to 'c.html.markdown')
-rw-r--r-- | c.html.markdown | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/c.html.markdown b/c.html.markdown index 92f07fe2..3fb6a83e 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -236,11 +236,9 @@ int main (int argc, char** argv) z = (e > f) ? e : f; // => 10 "if e > f return e, else return f." // Increment and decrement operators: - char *s = "ILoveC"; int j = 0; - s[j++]; // => "I". Returns the j-th item of s THEN increments value of j. - j = 0; - s[++j]; // => "L". Increments value of j THEN returns j-th value of s. + int s = j++; // Return j THEN increase j. (s = 0, j = 1) + s = ++j; // Increase j THEN return j. (s = 2, j = 2) // same with j-- and --j // Bitwise operators! |