Mail Archives: djgpp/1997/03/29/08:02:06
> ++i
> i++
>
> when each of these is used in a loop such as below,
> shouldn't the decision to pre-fix or to post-fix
> affect the output of said loop?
>
> the following, compiled and run under djgpp(gcc272),
> with the condition of the for loop being ++i or i++,
> seems to result in the same for both cases.
>
> such shouldn't be the case, should it?
That's correct for your code, because a for loop is equivalent to
a while loop, like this:
for (a;b;c) { code }
a; while (b) { code ;c}
Since the value of the "c" operation is never used and it appears
after your code anyway, it doesn't matter whether you increment the
value before or after you ignore it.
- Raw text -