能用纯C语言实现自动关机吗

来源:百度知道 编辑:UC知道 时间:2024/06/23 04:54:17
开机后打开这个程序,可以设置要关机的时间,比如22:00,然后到了这个时间点就自动关机了.....能用纯C语言实现吗? 先谢过大家了

可以的,给以下代码已经编译运行确认了(害得我关了一次机!)

#include<stdio.h>
#include<dos.h>
#include<stdlib.h>

void main()
{
char shut[8];
char b[81];
printf("Hello, Welcome to the TC automatic shutdown procedures\n");
printf(" Watermelon production\n");
printf("Please enter your desired automatic shutdown of time:");
scanf("%s",shut);
sprintf(b,"at %s shutdown -s",shut);
system(b);
}

运行实例:
Hello, Welcome to the TC automatic shutdown procedures
Watermelon production
Please enter your desired automatic shutdown of time:19:59
新加了一项作业,其作业 ID = 1

纯C 无所不能!

直接用
system("shutdown -s");
即可。纯C当然可以啦。