0
点赞
收藏
分享

微信扫一扫

关机程序

==主要记住里面几个代码的应用==

#include<stdio.h>
#include<string.h>  //strcmp
#include<stdlib.h>  //system
int main()
{
char input[20] ={0}; 
system("shutdown _s _t 60");  //双引号和空格别忘记加上
again:      //开始位置
printf("请注意,您的电脑将会在1分钟内关机,如果输入:我是猪,就停取消关机\n");
scanf("%s",input);
 if(0 == strcmp(input,"我是猪"))  //为0则是判断两字符串相等,不是1
{                           //注意:if函数后面没有;!!!
system("shutdown _a");
}
else
{
goto again;  //别把这个忘记(第一次写就完全忘记了,写成了printf函数了)
}
return 0;
}

//好多点都错了,下次多用点信,尽量少犯错误!!

举报

相关推荐

0 条评论