Both ++var
and var++
are identical when appear in expression alone.
This applies to your question because you have alone ++i
, i++
It difference only take place when you inline them:
int x = 0;
printf( "%d %d\n", ++x, x ); // 1 1
printf( "%d %d\n", x++, x ); // 1 2
How to remember?
When you see first the operator, then increment and later take value.
When you see first the variable, then take value and later increment.
So in first example you see equal values because:
you increment `x`, then access `x`, then access `x` again
So in second example you see differences because:
you access `x`, then increment `x`, then access `x` again