case

break

break is used to exit from a do, for, or while loop, bypassing the normal loop condition. It is also used to exit from a switch statement.

An example of break in a loop is shown here:

do {   x = getx();   if(x < 0) break; // terminate if negative    process(x); } while(!done);

Here, if x is negative, the loop is terminated.

In a switch statement, break keeps program execution from “falling through” to the next case. (Refer to the switch statement for details.)

A break terminates only the for, do, while, or switch that contains it. It will not break out of any nested loops or switch statements.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net