关机程序命令

int main()
{
char arr[20];
system("shutdown /s /t 120");//调用库函数system,需引用(stdlib.h)
again://可以用while(1)break代替来代替goto;
printf("温馨提示:你的电脑将在2分钟内关机,\n如果输入:我是猪;\n就取消关机\n请输入\n");
scanf("%s", &arr);
if ((strcmp(arr, "我是猪")) == 0)//引用库函数<stting.h>
{
system("shutdown /a");
}
else
{
goto again;//goto使程序跳转到again标识的地方,往后执行,标识语句后的冒号不能省略。
}
return 0;
}

posted @ 2022-12-09 14:04  小蠕虫  阅读(84)  评论(0)    收藏  举报