Q:

C 'switch' usage?

Possible Duplicate:
Need help solving 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'.
Would anyone explain?
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.

A:

defa1ut is not the same as default.
That's an unused and unreachable label.

A:

As SLaks pointed out, defa1ut is a user defined label (e.g. for a goto), not the switch keyword default. This is why you aren't seeing the expected output.
But to answer your other question, in C you can compare char literals with integers. In this case '1' has a numerical value of 49, assuming you are using the ASCII character set.
Assuming you meant default, and you are using ASCII, your code sample is equivalent to this:
      int a=10;
      switch(a)
      {
              case 49:             // ASCII value of '1'
                  printf("ONE\n");
                  break;
              case 50:             // ASCII value of '2'
                  printf("TWO\n");
                  break;
              default:
                  printf("NONE\n");
      }

