case '1'中的'1'是字符1,其值为十进制49,所以它与case 49是一个意思;而case 1中的1是数字1,就是十进制1了。下面的代码可帮助理解:
//#include "stdafx.h"//If the vc++6.0, with this line. #include "stdio.h" int main(void){ char x; scanf("%d",&x); switch(x){ case 1: printf("123\n");//输入1,则输出123 break; case '1': printf("abc\n");//输入49,即'1'则输出abc break; } return 0; }