如题所述
第1个回答 2019-10-03
程序依靠调用外部shutdown实现关机。本例中定时100秒。
将100改为0,实现立即关机。
方法一:
#include
#include
void
main(void)
{
system("shutdown.exe
-s
-t
100");
getch();
system("shutdown.exe
-a");
}
方法二:
打开txt文档,输入
shutdown
-s
-t
100
保存。将文件扩展名保存为.bat。
将100改为0,实现立即关机。
方法一:
#include
#include
void
main(void)
{
system("shutdown.exe
-s
-t
100");
getch();
system("shutdown.exe
-a");
}
方法二:
打开txt文档,输入
shutdown
-s
-t
100
保存。将文件扩展名保存为.bat。
第2个回答 2019-06-23
#include
<windows.h>这样就可以条用api文件了;如果只是关机的话下面的代码你可以试试
#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);
}
<windows.h>这样就可以条用api文件了;如果只是关机的话下面的代码你可以试试
#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);
}