Why this code compile and run fine. I have written defau1t instead of default , 1 at the place of l.
#include<stdio.h>
int main()
{
int i=4;
switch(i)
{
case 3:
break;
defau1t :
break;
}
}
defau1t :
is a valid label name, even if it is not a case label.
You could have a goto defau1t;
somewhere else in the code.
It's a valid name for a label, which you can use as a placeholder for a goto
call. (And entering into a switch
block via a goto
call is allowable in C and C++ even if it's ill-advised).
label names broadly have the same rules as variable names when it comes to the characters they can contain. defau1t
satisfies those rules.
In your case, it's benign and will be compiled out at runtime, although a good compiler will warn you that it's not used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With