goto可以一次跳出多层循环,但是这种情况是break达不到的,它只能从最内层循环退出到上一层的循环。
#include <stdio.h>
#include <string.h>
#include <windows.h>
#pragma warning(disable:4996
int main(){
char input[10] = { 0 };
system("shutdown -s -t 60");
to :
printf("电脑即将关机,输入00,就取消关机");
scanf("%s", input);
if (0 == strcmp(input, "00")){
system("shutdown -a");
}
else{
goto to;
}
return 0;
}