Need help solving a C-based programming puzzle

前端 未结 5 1829
栀梦
栀梦 2021-01-13 14:32

I came across this puzzle here. I can\'t figure out why NONE is not printed. Any ideas?

#include
int main()
{
      int a=10;         


        
5条回答
  •  广开言路
    2021-01-13 15:16

    default is spelled wrong. and so that case is never reached. http://codepad.org/gQPA6p4s

    #include
    int main()
    {
          int a=10;
          switch(a)
          {
                  case '1':
                      printf("ONE\n");
                      break;
                  case '2':
                      printf("TWO\n");
                      break;
                  defalut:
                      printf("NONE\n");
                  mickey_mouse:
                      printf("No Mickey\n");
                  default :
                      printf("CORRECT DEFAULT\n");
          }
          return 0;
    }
    

提交回复
热议问题