目录
1.goto语句
- goto语句:配合标签使用
- 但是没有goto跳转,3也会被打印
- goto语句的真正使用场景
- 如果使用break,需要好几个break,没有goto方便
2.goto语句实现关机程序
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char input[20] = {0};
system("shutdown -s -t 60");
again:
printf("电脑将会在一分钟内关机,输入:我是猪,则取消关机.请输入:>");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
system("shutdown -a");
else
{
goto again;
}
return 0;
}