break statement

break statement Exits from a loop or switch statement

statement := break ;

The break statement exits from the nearest enclosing loop (do, for, or while) or switch statement. Execution continues with the statement immediately following the end of the loop or switch. An error results if break is used outside of a loop or switch statement.

Example

while(std::cin >> x) {

  if (x < 0)

    break;

  data.push_back(x);

}

See Also

continue, do, for, statement, switch, while, Chapter 4