C语言学习第24篇---goto关键字使用

goto实现判断函数
#include <stdio.h> 
void main() {
    int age;

    gotolabel:  //注意是:
    printf("You are not eligible to vote!\n");
    printf("Enter you age:\n");
    scanf("%d", &age);
    if (age < 18) {
        goto gotolabel;  //跳转到gotolabel
    }else {
        printf("You are eligible to vote!\n");
    }
}


猜你喜欢

转载自blog.csdn.net/super828/article/details/80463415