continue 문 (C++)
제어를 가장 작은 바깥쪽, for 또는 while 루프의 제어 식으로 강제로 전송합니다.
구문
continue;
설명
현재 반복에서 나머지 모든 문은 실행되지 않습니다. 루프의 다음 반복은 다음과 같이 결정됩니다.
do
또는while
루프에서 다음 반복은 또는while
문의 제어 식을do
다시 평가하여 시작합니다.for
루프에서(구문을for( <init-expr> ; <cond-expr> ; <loop-expr> )
사용하여) 절이<loop-expr>
실행됩니다. 그런 다음<cond-expr>
절이 다시 계산되고 해당 결과에 따라 루프가 종료되거나 다른 반복이 발생합니다.
다음 예제에서는 문을 사용하여 코드 섹션을 무시하고 루프의 다음 반복을 시작하는 방법을 continue
보여 줍니다.
예제
// 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