Using multiple index values within a for loop.
(Another snippet I originally posted to CodeKeep on 23-Feb-2009.)
This one seems rather obvious, but if you don’t know…
Code:
for (int i = 0, j = 1; i < max; i++, j++)
{
// do something
}
Notes:
You can have any many initializers in the for loop definition as you like. Just make sure you index all of the values to avoid any infinite loops that might occur.
