这里直接上源码了:
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>//system的头文件
#include<string.h>//strcmp的头文件
int main()
{
char input[20] = { 0 };
system("shutdown -s -t 60");//关机命令
while (1)
{
printf("请注意,你的电脑将在1分钟内关机,如果输入:我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
{
system("shutdown -a");//取消关机命令
break;
}
}
return 0;
}