9-29

goto語句:放哪兒,goto就跳哪兒
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
printf("hehe\n");
goto bit;
printf("你是豬\n");
bit:
printf("dadad\n");
return 0;
}ide

用cmd命令使電腦關機:
shutdown -s -t 60
取消關機:shutdown -acode

用C語言,寫一行代碼讓電腦關機
system()-執行系統命令--要與頭文件#include<stdlib.h>
strcmp()-比較兩個字符串,要與頭文件#include<string.h>相對應字符串

//電腦關機程序
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char input[] = { 0 };
system("shutdown -s -t 60"); ////systen執行系統命令的,對應#include<stdlib.h>頭文件
again:
printf("請注意,你的電腦將在一分鐘內關機。 若是輸入:我是豬,就取消關機\n 請輸入>:");
scanf("%s" , input);
if (strcmp(input, "我是豬") == 0) ////strcmp比較兩個字符串是否相等,對應#include<string.h>
system("shutdown -a");
else
{
goto again;
}input

return 0;

}cmd

本站公眾號
   歡迎關注本站公眾號,獲取更多信息