August 2012
Intermediate to advanced
976 pages
30h 17m
English
break StatementA break statement terminates the nearest enclosing while, do while, for, or switch statement. Execution resumes at the statement immediately following the terminated statement.
A break can appear only within an iteration statement or switch statement (including inside statements or blocks nested inside such loops). A break affects only the nearest enclosing loop or switch:
string buf;while (cin >> buf && !buf.empty()) { switch(buf[0]) { case '-': // process up to the first blank for (auto it = buf.begin()+1; it != buf.end(); ++it) { if (*it == ' ') break; // #1, leaves the for loop // . . . } // break #1 transfers control here //
Read now
Unlock full access