#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*goto语句
C语言中提供了可以随意滥用的 goto语句和标记跳转的标号。
从理论上 goto语句是没有必要的,实践中没有goto语句也可以很容易的写出代码。*/
/*运行cmd,输入shutdown -s -t 60设置的s代表关机,t表示设置时间关机,60秒之后关机,动用的是shutdown这个工具 */
// shutdown -a取消关机
int main()
{
??? char input[20] = { 0 };
??? //关机
??? //C语言提供了一个函数:system()执行系统命令的
??? system("shutdown -s -t 60");//头文件是stdlib.h
assert:
??? printf("电脑将会在60s后强制关机,除非输入我是猪便可取消关机:");
??? scanf("%s", input);
??? if (strcmp("我是猪", input) == 0)
??? {
?????? system("shutdown -a");
?????? printf("恭喜小猪猪你,电脑已取消关机了");
??? }
??? else
??? {
?????? goto assert;
??? }
??? return 0;
}