Possible Duplicate:
Debugging a switch statement in a C-based programming puzzle
I found the below C question on web:
#include<stdio.h>
int main()
{
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut:
printf("NONE\n");
}
return 0;
}
Although I never used ‘switch’ of int ’10’ with char ‘1’, I assume the worst would be a non-compile, or ‘default’ get executed. But no, on my VStudio, it goes directly to ‘return 0’. Why is this?
By the way, although I had a few years of experience in C programming, my previous motto was to stick to MSDN or available code samples. Now with the interviews and questions, the solidness of my skill is definitely being challenged.
defa1utis not the same asdefault.That’s an unused and unreachable label.