for循环中的switch的break和continue作用范围
2024-08-21 03:52:31
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循环内的其他语句。
最新文章
- [LeetCode] Second Highest Salary 第二高薪水
- 在ubuntu 12.04 x64下编译hadoop2.4
- Java 使用Memcache
- Android中的“再按一次返回键退出程序”实现
- UIButton的titleEdgeInsets和imageEdgeInsets属性
- javascript对象转化为基本数据类型规则
- SQL笔记-第一章,数据库入门
- java1.8的几大新特性(二)
- WPF——执行命令清空文本框
- jQuey事件委托
- 微软 Office 2010 SP2 正式版下载大全(含简中)
- Linux中变量#,@,0,1,2,*,$$,$?的意思
- vue源码分析—认识	Flow
- Prometheus部署监控容器
- Python 入门知识捡漏
- 在form表单里上传图片
- Nlog日志组件简介
- Just Oj 2017C语言程序设计竞赛高级组A: 求近似值(矩阵快速幂)
- 石板地面 Base Shape
- C++ code:向量操作之添加元素
热门文章
- javascript getElementsByClassName扩展函数
- 个人项目-WC(Java实现)
- 一个APACHE TOMCAT漏洞修复
- Tomcat服务器编码格式设置
- kernel: nfsd: too many open TCP sockets, consider increasing the number of threads
- pod install/update失败:Failed to connect to 127.0.0.1 port 1080: Connection refused
- idea安装、配置及基本使用
- Jenkins集成allure测试报告
- 排序算法-快速排序(Java)
- Codeforces Round #135 (Div. 2) D - Choosing Capital for Treeland(两种树形DP)