switch case

September 18, 2009 at 03:42:24
Specs: Windows Vista, 2 GB DDR2
Hi I have the following code
-----------------code--------------------
#include<stdio.h>
int main()
{
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
abcd:
printf("NONE\n");
}
return 0;
}
-----------------------------------------------------
It compiles and runs. I don't have any problem but I don't understand what is the use of " abcd: " ? Why does it not cause compile error -- I mean what is the rationale of allowing it ?

See More: switch case

Report •


#1
September 18, 2009 at 04:54:29
I believe it is allowed because it is a valid label that could be jumped to using a goto. It would not be allowed as a case.

Report •
Related Solutions


Ask Question