c

for loop missing initialization


I've seen

for(;;)

and

for ( ; *s != '\0'; s++)

Why is it blank like that.


Solution

  • The for statement works like:

    for (initialization; test-condition; update)

    And any or all of those three can be omitted (left blank). So:

    1 The loop will still be interrupted if there's a break statement in the loop body, or a call to exit(), etc...