This is just a shorter way to write the same thing, and it only confuses those who do not deeply understand C (a) . The same argument can be made to replace:
for (i = 0; i < 10; i++) printf ("%d\n", i);
from:
i = 0; while (i < 10) { printf ("%d\n", i); i = i + 1; }
since any for can also be done using while or:
i = 0; loop: if (i < 10) { printf ("%d\n", i); i = i + 1; goto loop; }
since any loop construction can be built from conditions and goto . But (I hope) you would not do that, would you?
(a) I sometimes like to explain this to my students as simple statements and side effects, which allows the C-code to be shorter, usually unimportant, or with minimal loss of readability.
For approval:
y = x++;
the operator assigns x - y side effect, which then increases x . ++x is the same thing, it's just that a side effect happens in advance.
Similarly, the side effect of assignment is that it is evaluated as an assigned value, that is, you can do things like:
while ((c = getchar()) != -1) count++;
and does things like:
42;
valid but useless C. instructions
paxdiablo
source share