Abstract

The continue statement can be used to skip the rest of the body of an iterative loop. The use of a continue statement violates the rules of structured programming, however, and a section of code which uses a continue statement can always be rewritten to omit the continue.

Usage

The continue statement can be used to skip the rest of the body of an iterative loop.

Syntax

Syntax Diagrams

continue Statement Syntax Diagram

BNF

continue-statement
::= 'continue' ';'

EBNF

continue-statement
::= 'continue' ';'

Contextual Constraints

continue
The continue statement can only be used within the body of a while, do, or for statement.

Semantics

continue
The continue statement skips the remaining statements in the body of the loop, and continues with the next iteration of the loop.

Flowchart

Continue Statement Flowchart

Remarks

Example

Remarks

External Links

MSDN The C continue Statement Visual Studio 9.0 (2008), .NET 3.5
MSDN The C continue Statement Visual Studio 8.5, .NET 3.0
MSDN The C continue Statement Visual Studio 8.0 (2005), .NET 2.0
MSDN The C continue Statement Visual Studio 7.1 (2003), .NET 1.1
MSDN The C continue Statement Visual Studio 6.0

Example

#include <stdio.h>
#include <stdlib.h>

int main () {
  unsigned x;

  x = 0;
  while (x < 10) {
    ++x;
    if (x % 2 == 0) {
      continue;
    }
    printf ("%i is an odd number.\n", x);
  }

  return 0;
}

Output


    

Reference Links

break Statement <break-statement>

Other Languages

C Now
C continue Statement
C++ Now C++ continue Statement