First off, indent and space your code - it makes it a lot more readable. (I've done that for your question - see how much easier it is to see what is going on?)
The for loop is simple:
for (a; b; c)
d
1) Before the loop starts, the statement
a
is executed to initialise the loop.
2) Then the statement
b
is ecxcuted - if it returns a non-zero value the loop body
d
is executed, if not the loop exits.
3) After each time
d
has been executed,
c
is executed to advance the loop to the next iteration, and the process continues from (2) above.
Nice and simple, just like your code...
If you still don't understand your loop, then use the debugger to step through the loop while it is running and watch exactly what happens - that should help you to work it out in a few seconds.