Quote (flyinggoat @ 20 Aug 2013 21:43)
++i in the for loop increments i before it starts the first iteration. your loop starts at 1 instead of 0
look at this:
Code
#include <stdio.h>
void main(void){
for(int i=0; i<5; ++i)
printf("i: %d\n", i);
}
result is this:
Code
i: 0
i: 1
i: 2
i: 3
i: 4
because:
the last part in the for loop is executed AFTER the stuff in the for loop. therefore it doesn't matter if its i++ or ++i (in this case)
This post was edited by Richter on Aug 20 2013 03:31pm