使用C语言写的小的关机程序,可以通过编译exe可执行文件来使用
关机程序:也可以用cmd
关机命令:shutdown -s -t 60 60秒后关机
取消关机:shutdown -a
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char input[20] = { 0 };//存放输入信息
system("shutdown -s -t 60"); //system:执行系统命令的 头文件为stdlib.h
again:
printf("请注意, 你的电脑在1分钟内关机,如果输入:我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0) //strcmp返回值为0说明相等,两个字符的比较不能采用== 头文件为string.h
{
system("shutdown -a");
}
else
{
goto again;
}
return 0;
char input[20] = { 0 };//存放输入信息
system("shutdown -s -t 60"); //system:执行系统命令的 头文件为stdlib.h
while(1)
{
printf("请注意, 你的电脑在1分钟内关机,如果输入:我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0) //strcmp返回值为0说明相等,两个字符的比较不能采用== 头文件为string.h
{
system("shutdown -a");
break;
}
}
return 0;
}