cpp/language/for

Executes once, then executes  and  repeatedly, until the value of  becomes false. The test takes place before each iteration.

Explanation
The above syntax produces code equivalent to:

Except that @1@ The scope of and the scope of  are the same. @2@ The scope of and the scope of  are disjoint and nested within the scope of  and. @3@ in  will execute. @4@ Empty is equivalent to.

If the execution of the loop needs to be terminated at some point, can be used as terminating statement.

If the execution of the loop needs to be continued at the end of the loop body, can be used as shortcut.

As is the case with loop, if  is a single statement (not a compound statement), the scope of variables declared in it is limited to the loop body as if it was a compound statement.