Previous: The For Statement, Up: Expressions And Statements [Index]
The statement exits the innermost ‘while’, ‘do’ ‘while’ or ‘for’ block. The program execution is resumed with the first instruction following the block.
while (1) {
o_text("Bangkok\n");
break;
o_text("Thailand\n");
}
The fragment prints once Bangkok. Thailand is not printed, as the second print statement is never reached.
Read lines from a file and test them against a match target. Break the loop if the test is positive.
file f;
text s, t;
...
while (f_line(f, s) != -1) {
if (!compare(s, t)) {
break;
}
}