我是 C 语言新手,需要帮助。我的代码如下。
#include<stdio.h>
#include<conio.h>
void main()
{
int suite=2;
switch(suite)
{
case 1||2:
printf("hi");
case 3:
printf("byee");
default:
printf("hello");
}
printf("I thought somebody");
getche();
}
我在 Turbo C 中工作,输出是helloI thought somebody
。没有错误消息。
请让我知道这是如何运作的。
case 1||2:
Becomes true
。所以它变成了case 1:
但传递的值为 2。因此执行默认情况。之后你的printf("I thought somebody");
被执行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)