c/language/for

Executes a loop.

Used as a shorter equivalent of.

Explanation
Behaves as follows:


 * may be an expression.
 * An, which is an expression, is evaluated once, before the first evaluation of and its result is discarded.


 * is evaluated before the loop body. If the result of the expression is zero, the loop statement is exited immediately.
 * is evaluated after the loop body and its result is discarded. After evaluating, control is transferred to.

,, and are all optional. If is omitted, it is replaced with a non-zero integer constant, which makes the loop endless:

is not optional, but it may be a null statement:

If the execution of the loop needs to be terminated at some point, a can be used anywhere within the.

The used anywhere within the  transfers control to.