Reputation: 560
is this valid C code ? Is possible to have switch in switch ?
switch (i){
case 1:
switch(c){
case 1:
c = 0;
break;
case 3:
c = 5;
break;
}
case 2:
// another code
}
Upvotes: 0
Views: 248
Reputation: 56519
C++ § 6.4.2 / 4
Switch statements can be nested; a case or default label is associated with the smallest switch enclosing it.
Upvotes: 4
Reputation: 45450
Yes, to have switch in switch is valid.
§ 6.4.2 The switch statement
4 Switch statements can be nested; a case or default label is associated with the smallest switch enclosing it.
Upvotes: 12