当前位置:网站首页>C语言 关机小程序
C语言 关机小程序
2022-07-26 22:37:00 【TheshyO_o】
目录
关机小程序
这串代码运行起来,电脑就会倒计时在一分钟内关机,如果输入我是猪,就会取消关机。
这里我们运用了一串代码shutdown -s -t 60。
shutdown是关机,-s设置关机,-t设置时间关机,60设置时间。
C语言提供了一个函数system(执行系统命令),头文件stdlib.h。
我们把shutdown -s -t 60放到system里面。
运行起来,系统就会执行shutdown -s -t 60。
shutdown -a是取消关机,当然shutdown -a也要放到system里面。
当输入我是猪时。
系统就会执行shutdown -a来取消关机。
int main()
{
char password[20] = { 0 };
printf("请输入我是猪,不然电脑将会在一分钟后关机\n");
system("shutdown -s -t 60");
again:
scanf("%s", password);
if (strcmp(password, "我是猪") == 0)
system("shutdown -a");
else
{
printf("%再给你一次机会\n");
goto again;
}
return 0;
}写完这串代码后,运行一下就可以在代码保存的文件夹里找到这串代码转换成的exe文件
点击exe可执行程序便可直接运行这串代码,也可以给exe文件改个名字再换个图标来分享给我们的小伙伴们。
友情小贴士:

在这里搜索服务,然后通过一顿操作把这个可执行程序保存进服务里,设置成开机自启动,60秒后关机也可以改成任意时间。这样一开机就会直接运行这段代码,电脑一开机便已经走在了关机的路上。
当然,这样容易没朋友,不建议大家去尝试。
边栏推荐
- Collection of 3D LUT related articles
- Convolutional neural network -- lenet (pytorch Implementation)
- 蒙着头配置deeplabcut2
- When the label begins with "IMS", why does logcat not print the log?
- Sliding window problem summary
- uni-app学习(二)
- 三层架构 模拟
- PTA 7-4 small generation (DFS)
- Halloween treatments (drawer principle)
- Transpose convolution correlation
猜你喜欢

ResNet论文解读及代码实现(pytorch)

放图仓库-2(函数图像)

Complete review of parsing web pages

3_Jupyter Notebook, numpy和matplotlib

Leetcode topic - array

机器人学台大林教授课程笔记

Anaconda => PyCharm => CUDA => cudnn => PyTorch 环境配置

Leetcode - hash table

Mysql database complex operations: Database Constraints, query / connect table operations

13_集成学习和随机森林(Ensemble Learning and Random Forests)
随机推荐
CSDN article syntax rules
蒙着头配置deeplabcut2
Topological sorting (learning notes) introduction + judge whether there is a ring
放图仓库-2(函数图像)
Drawing warehouse Tsai
7_ Principal component analysis
Oracle data guard service, process and protection mode
AlexNet(Pytorch实现)
4. Talk about the famous Zhang Zhengyou calibration method
10_评价分类结果(Evaluate classification)
Uni app learning (II)
Mysql8 installation
Relationship between Unicode and UTF-8
[LeetCode] 无重复最长字符串
Codeforces C1. Simple Polygon Embedding
Helicopter control system based on Simulink
C and pointer Chapter 18 runtime environment 18.2 interface between C and assembly language
4-4 object lifecycle
100. Same tree
裁剪tif影像