Suppose I have a piece of C code
while(1)
{
switch(a){
case 1:
if(b==1)
break;//first break
break;//second break
}
}
Will the second break get me to continue the while(1) loop and the first break get me to break out of the while(1) loop even though the first break is inside second break?
The order seems to be changed here on breaks. What is the C language implementation standard on this?
C 2024 6.8.7.4 says:
A
break
statement terminates execution of the innermost enclosingswitch
or iteration statement.
Therefore a break
whose innermost enclosing switch
or iteration statement is a switch
statement terminates execution of that switch
statement.