Tuesday, September 21, 2010

Nested switch Statements

You can have a switch as part of the statement sequence of an outer switch. Even if the
case constants of the inner and outer switch contain common values, no conflicts arise.
For example, the following code fragment is perfectly acceptable:
switch(x) {
case 1:
switch(y) {
case 0: printf("Divide by zero error.\n");
break;
case 1: process(x,y);
}
break;
case 2:
.
.
.

No comments:

Post a Comment