TOC | Prev | Next

for

A for loop is the same as a while loop with some syntactic
sugar.

Here we count from 1 to 10.

int i;
for ( i = 1; i <= 10; ++i ) {
    printf( "%d\n", i );
}

Anything can go in the for, but don't go crazy.

/* YUCK */
for ( call_some_setup(); godot_not_here(); counter += 8 ) {
    /* do nothing */
}
TOC | Prev | Next