switch语句的一些规则
2015-10-06 10:05
281 查看
看contiki源码时,process的断点恢复的地方,有如下例子的用法
#if 1
#include <stdio.h>
#include <assert.h>
int main()
{
int ch;
int whl = 5;
printf("enter:\n");
scanf_s("%d",&ch);
switch(ch)
{
case 0:
printf("case 0\n");
printf("if(1)\n");
if (ch==0)
{
case 1:
printf("{\ncase 1\n}\n\n");
}
while (whl>0)
{
case 2:
printf("whl=%d\n",whl);
whl--;
}
}
system("pause");
return 0;
}
#endif
case2会继续循环
感觉以前太不注意细节了
#if 1
#include <stdio.h>
#include <assert.h>
int main()
{
int ch;
int whl = 5;
printf("enter:\n");
scanf_s("%d",&ch);
switch(ch)
{
case 0:
printf("case 0\n");
printf("if(1)\n");
if (ch==0)
{
case 1:
printf("{\ncase 1\n}\n\n");
}
while (whl>0)
{
case 2:
printf("whl=%d\n",whl);
whl--;
}
}
system("pause");
return 0;
}
#endif
case2会继续循环
感觉以前太不注意细节了
相关文章推荐
- PHP8新特性之match表达式
- 三个有用的 Switch 命令
- js 中的switch表达式使用示例
- php中switch与ifelse的效率区别及适用情况分析
- c#中switch case的用法实例解析
- Go语言中的switch用法实例分析
- php switch语句多个值匹配同一代码块应用示例
- 解析c语言switch中break语句的具体作用
- PHP的switch判断语句的“高级”用法详解
- php中switch语句用法详解
- Repeater里switch的使用方法
- javascript使用switch case实现动态改变超级链接文字及地址
- JavaScript中switch语句的用法详解
- JavaScript中switch判断容易犯错的一个细节
- javascript的switch用法注意事项分析
- javascript中if和switch,==和===详解
- Java中switch判断语句典型使用实例
- Asterisk DialPlan Switch
- cisco switch 配置(vlan划分,生成树和高级生成树,高级特性,vlan路由)
- EtherChannel Between a Cisco Catalyst Switch and Server Configuration Example