我收到了一个问题,并被要求提供输出.
int main(void){
int x = 2;
switch(x){
case 1,2,1: printf("Case 1 is executed");
break;
case 2,3,1: printf("Case 2 is executed");
break;
default : printf("Default case us executed");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在Turbo C中给出了"Case 1 is execution"的输出,但是在代码块和在线编译时,它给出了编译器错误.
哪一个是正确的?这是编译器错误吗?如果没有,为什么代码只在Turbo C上运行?