天天看点

c语言go to 语句实现60秒内自关机

#include <stdio.h>

#include <string.h>

//#include< stdlib.h>

//shutdown -s -t 60

//shutdown -a

int main()

{//关机程序

   char input[30] = { 0 };

   system("shutdown -s -t 60");//system()-执行系统命令

   again:

   printf("电脑将在1分钟内关机,如果输入:我是猪,就取消关机!\n请输入:>");

   scanf("%s", input);

   if (0 == strcmp(input, "我是猪"))

   {

       system("shutdown -a");

   }

   else

   {

       goto again;

   }