当前位置:网站首页>Goto statement to realize shutdown applet
Goto statement to realize shutdown applet
2022-06-26 12:58:00 【Small protrusion ~】
C The language provides a language that can be abused at will goto Statement and mark the label of jump . In theory, goto Statements are not necessary , In practice, there is no goto Statements can also easily write code . and goto A statement simply jumps to the symbol , This symbol is not fixed , It can be any other letter . Here are two demonstration pictures .
goto Statements cannot jump across functions
goto The most common use of statement is to terminate the processing of the structure of the program nested in some depth .
for instance , Such a three-tier for loop , If you want to jump out of the loop, do you have to use three break. While using goto Statement can jump out of the three-level loop .
Next , I'm going to introduce one that uses goto Statement to implement the shutdown applet .
First of all, we need to open and run , Input cmd, Open the command line window , and shutdown It is the system command to shut down the computer .
and shutdown -s Indicates that the shutdown is set ,shutdown -t Indicates the set time to shut down ,shutdown -60 Express 60s Power off after shutdown -a Indicates the command to release the shutdown .


You can try , I know if your computer will shut down .
And in the c In language , We need to use system This system function executes system commands . Then a shutdown program must start up , At this time, we should remind others , Otherwise, it will be shut down . Then, the input string is compared with “ I am a pig ” Compare , The next step is to write the system commands wherever they should be .
#include <stdlib.h>
#include <string.h>
int main()
{
char input[20] = { 0 };
int i = 0;// Input times
system("shutdown -s -t 60");
again:
printf(" Please note that , Your computer will shut down in a minute , If input : I am a pig , Then cancel the shutdown \n");
scanf("%s", input);
if (i > 10)
{
system("shutdown -s -t 0");
}
if (strcmp(input, " I am a pig ") == 0)
{
system("shutdown -a");
}
else
{
i++;
goto again;
}
return 0;
}
My shutdown procedure also stipulates a Input times , If you don't lose “ I am a pig ”, that 10 After that, your computer will be turned off . The blogger really tried , I really turned it off . This is a simple shutdown applet . I hope I can help you , Learn programming , Can't always be so boring .
边栏推荐
- Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S
- NLP-D60-nlp比赛D29
- Word文档导出(使用固定模板)
- 由错误<note: candidate expects 1 argument, 0 provided>引发的思考
- 栈,后入先出
- Redis learning - 01 introduction, installation and configuration
- Fengshentai old shooting range Kali series
- Wechat applet wx Request request encapsulation
- Ubuntu安装配置PostgreSQL(18.04)
- Nodejs framework express and KOA
猜你喜欢
![[solved] data duplication or data loss after laravel paginate() paging](/img/68/7bf51bbf893a91bee24f5f7d4a369f.jpg)
[solved] data duplication or data loss after laravel paginate() paging

NoSQL mongodb - 04 mongodb database and web service combination case

PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)

BigInt:处理大数字(任意长度的整数)

Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology

Introduction to the four major FPGA manufacturers abroad

processing 随机生成线动画

power designer - 自定义注释按钮

Lightflow completed the compatibility certification with "daocloud Enterprise Cloud native application cloud platform"

【网络是怎么连接的】第二章(下):一个网络包的接收
随机推荐
Sharing ideas for a quick switch to an underlying implementation
Fengshentai old shooting range Kali series
TSMC Samsung will mass produce 3nm chips in 2022: will the iPhone be the first?
2022 edition of investment analysis and "fourteenth five year plan" development prospect forecast report of China's switchgear industry
7-2 数的三次方根
【shell】生成指定日期之间的字符串
power designer - 自定义注释按钮
JS get the current screen height method and listen for DOM elements to enter the viewport
中科软外包一面
Websocket and socket IO case practice
7-1 数的范围
Laravel+gatewayworker completes the im instant messaging and file transfer functions (Chapter 4: server debugging errors)
美学心得(第二百三十八集) 罗国正
NoSQL mongodb - 02 mongodb server installation, mongodb shell, basic concepts and visualization tools
计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)
一个初级多线程服务器模型
Several methods added to the ES6 array (foreach, filter, some, every. Includes, reduce)
详细实操分享,下班刷了两小时的搞笑视频,一个月收益7000多
Ubuntu安装配置PostgreSQL(18.04)
环形队列php