goto and lable
发布日期:2021-06-30 22:14:52 浏览次数:3 分类:技术文章

本文共 769 字,大约阅读时间需要 2 分钟。

/*** @file LableAndGoto.cpp* @brief goto and lable, 测试goto和标号的关系* @note 试验结果, 标号也是有作用域的, 标号只在函数内部有效* 不同函数中有同名的标号,不影响程序有效和编译结果* 使用goto和标号, 使错误处理过程简洁, goto 仅限于函数内, 进行错误处理的跳转** 试验环境: winxpSp3 + vs2005Sp1*/#include "stdafx.h"void function1();void function2();void function3();int _tmain(int argc, _TCHAR* argv[]){	function1();	function2();	function3();	goto END;	function1();	function2();	function3();END:	/** run results	function1(): a = 2	function2(): a = 3	function3(): a = 4	*/	getchar();	return 0;}void function1(){	int a = 1;	a++;	goto END;END:	_tprintf(_T("function1(): a = %d\n"), a);}void function2(){	int a = 2;	a++;	goto END;END:	_tprintf(_T("function2(): a = %d\n"), a);}void function3(){	int a = 3;	a++;	goto END;END:	_tprintf(_T("function3(): a = %d\n"), a);}

转载地址:https://lostspeed.blog.csdn.net/article/details/6630500 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:无缓冲区写文件
下一篇:整理: 关于程序员的漫画

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月12日 20时36分59秒