強制將控制權傳送至最小封入 do、 for 或 while 迴圈的控制表達式。
語法
continue;
備註
目前反覆項目中其餘的任何陳述式都不會執行。 迴圈中下一個反覆項目的判斷方式如下:
do在 或while迴圈中,下一個反覆專案會從重新評估 或do語句的控制while表達式開始。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