C++goto;与break;continue区别

goto就是跳过,一般是

        FLAG goto;

        ......(这部分就不执行)

        goto:

#include
using namespace std;

int main()
{

	cout << "a1" << endl;
	goto FLAG;//以下到“FLAG:”全部跳过,不执行指令,故不显示

	cout << "a2" << endl;
	cout << "a3" << endl;
	cout << "a4" << endl;

	FLAG://以上到“goto FLAG;”全部跳过,不执行指令,故不显示
	cout << "a5" << endl;

	
}

C++goto;与break;continue区别_第1张图片

break 直接跳出本次循环(一次只能跳一次循环)
continue 跳过本次循环执行继续下一次循环
goto 跳过到指定位置(嵌套啥的一下子跳出去了)

你可能感兴趣的:(C++goto;与break;continue区别)