关机代码 c语言
如下
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char arr[20] = { 0 };
system("shutdown -s -t 60");
again:
printf("请注意,你的电脑在1分钟内关机,如果输入:我是猪,就取消关机\n");
scanf("%s", arr);
if (strcmp(arr, "我是猪")==0)
{
system("shutdown -a");
}
else
{
goto again;
}
}
shutdown -a 是关闭关机指令
==不能用来比较俩个字符串是否相等,应该使用一个库函数-strcmp 头文件string.h
今天也是学习c语言的一天