for循环中的switch的break和continue作用范围

不空泛的讲理论了,上代码。看下面这个代码:

#include <stdio.h>
#include <stdlib.h>
int main ()
{
char str[] = "SSSWLLIJKA";
char c;
int k;
for(k=2;(c=str[k]) != '\0';k++)
{
switch(c)
{
case 'I' :++k;break;//跳出switch,执行for循环内switch外的其他语句
case 'L' :continue;
default:putchar(c);continue;
}
putchar('*');
}
return 0;
}

我们再看一下运行结果:

SW*KA

在这里我们可以看出这里的break的作用仅仅对switch有作用,并没有跳出for循环。而continue的作用域包含for循环内的其他语句。

最新文章

  1. [LeetCode] Second Highest Salary 第二高薪水
  2. 在ubuntu 12.04 x64下编译hadoop2.4
  3. Java 使用Memcache
  4. Android中的“再按一次返回键退出程序”实现
  5. UIButton的titleEdgeInsets和imageEdgeInsets属性
  6. javascript对象转化为基本数据类型规则
  7. SQL笔记-第一章,数据库入门
  8. java1.8的几大新特性(二)
  9. WPF——执行命令清空文本框
  10. jQuey事件委托
  11. 微软 Office 2010 SP2 正式版下载大全(含简中)
  12. Linux中变量#,@,0,1,2,*,$$,$?的意思
  13. vue源码分析—认识 Flow
  14. Prometheus部署监控容器
  15. Python 入门知识捡漏
  16. 在form表单里上传图片
  17. Nlog日志组件简介
  18. Just Oj 2017C语言程序设计竞赛高级组A: 求近似值(矩阵快速幂)
  19. 石板地面 Base Shape
  20. C++ code:向量操作之添加元素

热门文章

  1. javascript getElementsByClassName扩展函数
  2. 个人项目-WC(Java实现)
  3. 一个APACHE TOMCAT漏洞修复
  4. Tomcat服务器编码格式设置
  5. kernel: nfsd: too many open TCP sockets, consider increasing the number of threads
  6. pod install/update失败:Failed to connect to 127.0.0.1 port 1080: Connection refused
  7. idea安装、配置及基本使用
  8. Jenkins集成allure测试报告
  9. 排序算法-快速排序(Java)
  10. Codeforces Round #135 (Div. 2) D - Choosing Capital for Treeland(两种树形DP)