当前位置:网站首页>goto语句
goto语句
2022-04-22 07:50:00 【圣喵】
goto语句
C语言中提供了可以随意滥用的goto语句和标记跳转的标号。从理论上goto也可以很容易写出代码,但由于该语句太过于随意,在程序中可以随意跳前跳后,打乱原本程序的执行流程,使得执行流程并不怎么清晰,再加上各种变量状态的变化,我们就很容易编写出错误的代码。所以一般我们都不会用goto语句编写程序。
从理论上来说,goto语句是没有必要的,实践中没有goto语句也可以很容易写出代码。但某种场合下goto语句还是用得着的,最常见的用法就是终止程序在某些深度嵌套的结构的处理过程,这样就不用一层一层的break了,例如:

goto语句的用法是,先在设置一个跳转的位置kaa:,然后在你想跳转的时候编写代码goto kaa;,还有值得注意的时goto语句时不能跨函数跳转的,例如:


这份博客如果对你有帮助,给博主一个免费的点赞以示鼓励欢迎各位点赞评论收藏️,谢谢!!!
如果有什么疑问或不同的见解,欢迎评论区留言欧。
版权声明
本文为[圣喵]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_66769266/article/details/124256913
边栏推荐
- 工业缺陷检测项目实战(四)——基于HRNet的陶瓷缺陷检测
- CSDN如何转载文章
- PCIe learning - basic concepts of PCIe bus (6)
- DTV terminology
- Fabric test example, encountered order exited (x) x seconds
- 关于局部变量和整体变量的区别
- Hyperledger Fabric1. 4 environment construction and example test
- String replacement
- Autumn recruitment job summary and sharing
- 100. Same tree (easy)
猜你喜欢

RHEL 用户和组的管理-笔记

pycharm

Level 3: node quota and other commands

236. The nearest common ancestor of a binary tree (medium)

PCIe学习-PCIe总线怎样做到在软件上兼容PCI总线(七)

Disk management - raid creation

Aircrack 破解无线网密码 (跑字典法)

SQL 语句中 “意想不到” 的操作

235. Nearest common ancestor of binary search tree (easy)

Hyperledger Fabric1.4環境搭建及示例測試
随机推荐
RHEL7 逻辑卷管理-笔记
使用art-template继承时CompileError: Invalid or unexpected token generated
ROM、RAM、SRAM、DRAM、Flash、SDRAM区别
机器学习之分类回归树
CASE WHEN 及 SELECT CASE WHEN的用法 非常好用
100. Same tree (easy)
Freshman advice
聚看点 (详细版) 吃低保 每天几毛 青龙
require-dev.mikey179/vfsStream is invalid, it should not contain uppercase characters. Please use m
Client and server project 3
mysql导出表的具体字段信息(Navicat客户端详细操作)
String replacement
idea中@Data注解,get/set方法不起作用
VMware虚拟机通信与联网
MFC demo of data encoding
elastic-job安装部署接入
PCIe学习-PCIe总线体系结构入门:事务层-数据链路层-物理层(八)
Tencent video automatic check-in detailed version (V value obtained by multiple methods)
DTV terminology
微信小程序手机号码如何进行解密