天天看點

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;

   }