当前位置:网站首页>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 .
边栏推荐
- 无人机遥感在森林监测的部分应用研究案例总结
- Examples of how laravel uses with preload (eager to load) and nested query
- [solved] data duplication or data loss after laravel paginate() paging
- KVM 显卡透传 —— 筑梦之路
- ES6模块
- EasyGBS如何解决对讲功能使用异常?
- Thinkphp5 query report: sqlstate[hy093]: invalid parameter number
- Processsing 鼠标交互 学习
- PHP uses laravel pay component to quickly access wechat jsapi payment (wechat official account payment)
- 手把手带你学会Odoo OWL组件开发(7):OWL项目实战使用
猜你喜欢

Software testing - Fundamentals

Openlayers drawing dynamic migration lines and curves

A must for programmers, an artifact utools that can improve your work efficiency n times

第十章 设置结构化日志记录(二)
solo 博客系统的 rss 渲染失败

openlayers 绘制动态迁徙线、曲线

el-form-item 包含两个input, 校验这两个input

"Pinduoduo and short video speed version", how can I roast!

Research and development practice of Kwai real-time data warehouse support system
![[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]](/img/13/c2c63333a9e5ac08b339449ea17654.jpg)
[solved] laravel completes the scheduled job task (delayed distribution task) [execute a user-defined task at a specified time]
随机推荐
记一次phpcms9.6.3漏洞利用getshell到内网域控
栈,后入先出
PHP get directory size
7-2 数的三次方根
班主任让开股票账户,在挖财理财开户安全吗?
Photoshop 2022 23.4.1增加了哪些功能?有知道的吗
几行代码就能实现复杂的 Excel 导入导出,这个工具类真心强大!
Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S
Analysis report on the "fourteenth five year plan" and investment prospect of China's pharmaceutical equipment industry 2022-2028
Xiaobai lazy special-win10-win11 one click installation version
软件测试 - 概念篇
7-16 货币系统Ⅰ
710. 黑名单中的随机数
[极客大挑战 2019]RCE ME 1
四类线性相位 FIR滤波器设计 —— MATLAB源码全集
Learning directory
Implementing mixins scheme in applet
做自媒体视频的各种常用工具合集奉上
Generate JDE dot train
使用SSH密钥对登陆服务器