goto
c语言中提供了可以随意滥用的goto语句和标记跳转的标号;这些跳转也只能在一个函数程序中使用
goto的基本用法示例
#include "stdio.h"
int main(){
int count = 0;
flag:
printf("hehe\n");
printf("haha\n");
goto flag;
return 0;
}
goto的实际的应用场景
终止程序的深度嵌套结构处理过程
#include "stdio.h"
int main(){
for(...){
for(...){
for(...){
if(error){}
goto error;
}
}
}
error:
process;
return 0;
}