一个惊险又刺激的游戏
#include <stdlib.h>
#include <string.h>
int main()
{
char input[20] = { 0 };
//shotdown -s -t 60 60秒内关机
//shotdown-a 取消关机
//cmd command 命令行
//system() 执行系统的命令
system("shutdown -s -t 60");
again:
printf("请注意,你的电脑在一分钟内关机,如果输入:我是猪,就取消关机\n");
scanf("%s", input);
if (strcmp(input, "我是猪") == 0)//strcmp()专门比较两个字符串的函数
{
system("shutdown -a");
}
else
{
goto again;
}
return 0;
}
了解两个新的函数
1,系统函数systen("..."),可以执行系统函数
2,strcmp(,)函数,可以判断两个字符串