转向语句 goto语句

语句标号是一种用来标识语句的标识符,用冒号分割

#include<iostream>
using namespace std;
//goto只能在一个函数体内进行转向
int main(){
    int i;
    for( i=0;i<100;i++)
        if(i==50)
            goto found;
        cout<<"Not found!"<<endl;
        goto end;
        found:cout<<i<<endl;//found语句
        end:;//end标志是一个空语句
}

猜你喜欢

转载自blog.csdn.net/qq_40507857/article/details/84747883