目录

continue statement

C编程中的continue语句有点像break语句。 它强制执行循环的下一次迭代,而不是强制终止,跳过其间的任何代码。

对于for循环, continue语句会导致条件测试并增加循环的部分来执行。 对于whiledo...while循环, continue语句使程序控制传递给条件测试。

语法 (Syntax)

C语言中continue语句的语法如下 -

continue;

流程图 (Flow Diagram)

C继续声明

例子 (Example)

#include <stdio.h>
int main () {
   /* local variable definition */
   int a = 10;
   /* do loop execution */
   do {
      if( a == 15) {
         /* skip the iteration */
         a = a + 1;
         continue;
      }
      printf("value of a: %d\n", a);
      a++;
   } while( a < 20 );
   return 0;
}

编译并执行上述代码时,会产生以下结果 -

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
↑回到顶部↑
WIKI教程 @2018