6.11. The continue StatementA continue statement causes the current iteration of the nearest enclosing loop to terminate. Execution resumes with the evaluation of the condition in the case of a while or do while statement. In a for loop, execution continues by evaluating the expression inside the for header. For example, the following loop reads the standard input one word at a time. Only words that begin with an underscore will be processed. For any other value, we terminate the current iteration and get the next input: string inBuf; while (cin >> inBuf && !inBuf.empty()) { if (inBuf[0] != '_') continue; // get another input // still here? process string ... } A continue can appear only inside a for, while, or do while loop, including inside blocks nested inside such loops.
![]() |