Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The continue statement passes control to the next iteration of the nearest enclosing do, for, or while statement in which it appears, bypassing any remaining statements in the do, for, or while statement body.
Syntax
jump-statement:
continue ;
The next iteration of a do, for, or while statement is determined as follows:
Within a
door awhilestatement, the next iteration starts by reevaluating the expression of thedoorwhilestatement.A
continuestatement in aforstatement causes evaluation of the loop expression of theforstatement. Then the code reevaluates the conditional expression. Depending on the result, it either terminates or iterates the statement body. For more information on theforstatement and its nonterminals, see Theforstatement.
Here's an example of the continue statement:
while ( i-- > 0 )
{
x = f( i );
if ( x == 1 )
continue;
y += x * x;
}
In this example, the statement body is executed while i is greater than 0. First f(i) is assigned to x; then, if x is equal to 1, the continue statement is executed. The rest of the statements in the body get ignored. Execution resumes at the top of the loop with the evaluation of the loop's test.