c语言goto语句是什么意思

如题所述

goto是程序跳转语句。goto后面接一个标号,标号名字自己起。
比如
p1:a=a+1;
b=b+1;
goto p1;
程序执行到goto p1;就从a=a+1;开始执行。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-04-24
不建议使用goto语句,但是遇到goto语句我们要知道是什么 意思。
goto语句又叫无条件转移语句,强制跳转。
先看一个例子:
void main(){
int a=2,b=3;
if(a<b)
goto aa;
printf("hello");
aa:printf("s");
return 0;
}
改程序的执行结果为s
所有在goto aa这句之后直接跳转到aa:printf("s");
aa:为标记行。冒号切记不可省略。
反之如果代码这样子
void main(){
int a=2,b=3;
if(a>b)
goto aa;
printf("hello");
aa:printf("s");
return 0;
}
那么执行结果就是hellos
可以看到执行了 printf("hello"); aa:printf("s");
aa:将没有意义。
第2个回答  2013-09-21
跳转到goto后面的标示的地方继续执行。不过,一般都不用这种方式,代码不清晰
第3个回答  2013-09-21
C有goto么?就算有应该也不建议使用的。

跳转~~~
相似回答