mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
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.
This commit is contained in:
parent
161edb1f6e
commit
c8fb84cc91
@ -236,11 +236,9 @@ int main (int argc, char** argv)
|
|||||||
z = (e > f) ? e : f; // => 10 "if e > f return e, else return f."
|
z = (e > f) ? e : f; // => 10 "if e > f return e, else return f."
|
||||||
|
|
||||||
// Increment and decrement operators:
|
// Increment and decrement operators:
|
||||||
char *s = "ILoveC";
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
s[j++]; // => "I". Returns the j-th item of s THEN increments value of j.
|
int s = j++; // Return j THEN increase j. (s = 0, j = 1)
|
||||||
j = 0;
|
s = ++j; // Increase j THEN return j. (s = 2, j = 2)
|
||||||
s[++j]; // => "L". Increments value of j THEN returns j-th value of s.
|
|
||||||
// same with j-- and --j
|
// same with j-- and --j
|
||||||
|
|
||||||
// Bitwise operators!
|
// Bitwise operators!
|
||||||
|
Loading…
Reference in New Issue
Block a user