您的位置:首页 > 编程语言 > C语言/C++

【C语言】一分钟后关机

2015-10-11 15:00 369 查看
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
char input[10];

system("shutdown -s -t 60");
flag:
printf("1分钟之后关机,请输入\"我是猪\"三个字解除\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)
{
system("shutdown -a");
}
else
{
goto flag;
}
return 0;
}

补充:-s 是关闭此计算机 -t 是延迟多长时间关闭 ,后面跟秒数 例如 shutdown -s -t 60 意思是说60秒后关闭此计算机,shutdown -a是解除关机命令。

本文出自 “Vs吕小布” 博客,请务必保留此出处http://survive.blog.51cto.com/10728490/1701801
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: