Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

continue Statement (C++)

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see continue Statement (C++) on docs.microsoft.com. Forces transfer of control to the controlling expression of the smallest enclosing do, for, or while loop.

continue;  

Any remaining statements in the current iteration are not executed. The next iteration of the loop is determined as follows:

  • In a do or while loop, the next iteration starts by reevaluating the controlling expression of the do or while statement.

  • In a for loop (using the syntax for(init-expr; cond-expr; loop-expr)), the loop-expr clause is executed. Then the cond-expr clause is reevaluated and, depending on the result, the loop either ends or another iteration occurs.

The following example shows how the continue statement can be used to bypass sections of code and begin the next iteration of a loop.

// continue_statement.cpp  
#include <stdio.h>  
int main()  
{  
    int i = 0;  
    do  
    {  
        i++;  
        printf_s("before the continue\n");  
        continue;  
        printf("after the continue, should never print\n");  
     } while (i < 3);  
  
     printf_s("after the do loop\n");  
}  

before the continue  
before the continue  
before the continue  
after the do loop  

Jump Statements
Keywords

Show:
© 2017 Microsoft