C / C ++中的goto语句
goto语句是一个跳转语句。在一个函数中,它用于从一个语句跳转到另一个语句。强烈建议不要使用此语句。这使得程序变得复杂且难以追踪程序的控制流。很难修改程序。
这是用C语言编写的goto语句的语法,
goto label; . . . label: statement;
这是用C语言编写的goto语句的示例,
示例
#include <stdio.h>
int main () {
int a = 10;
LOOP:do {
if( a == 12) {
a = a + 1;
goto LOOP;
}
printf("Value of a: %d\n", a);
a++;
}while( a < 15 );
return 0;
}输出结果
Value of a: 10 value of a: 11 value of a: 13 value of a: 14
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短