i++ increments the i variable.
So...
1 2 3
|
int i = 0; // i == 0
i++; // now, i == 1
i++; // now, i == 2
|
The way for loops work:
|
for( initialization; condition; increment )
|
'initialization' is done exactly once, when the loop is first started.
'condition' is done before the loop takes another iteration.
'increment' is done after the loop completes an iteration.
So basically how this works....
1 2
|
for (i=0; i<5; i++)
a[i] = 0;
|
The computer will do the following:
1) Do the for loop initialization (i=0)
2) Check the loop condition (i<5 .. which is true). Since it's true, it will perform the loop
3) perform loop body (a[i] = 0, since i=0, this means a[0] = 0)
4) Now that the loop body is complete, do the loop increment (i++). Now, i=1
5) Check loop condition again (i<5, which is still true).
6) Do the loop body again. This time i=1, so a[1] = 0
7) Increment again, i=2
//...
It eventually stops when i=5, because (i<5) is no longer true.
EDIT: doh, too slow. Ninja'd twice!