C++goto语句用法
目录
C++goto语句用法
1、goto语句
2、代码演示
1、goto语句
goto语句又叫跳转语句,可以跳转到标志语句,执行下面操作;
goto 标记;
A
标记:
B
A语句不执行,执行B语句
2、代码演示
#include<iostream>
using namespace std;
int main() {
//goto语句
cout << "1" << endl;
cout << "2" << endl;
goto flag;//flag是标记
cout << "3" << endl;
cout << "4" << endl;
flag:
cout << "5" << endl;
system("pause");
return 0;
}
1
2
5
请按任意键继续. . .