当前位置:首页 > 通信资讯 > 正文

c语言关机程序(c语言关闭程序命令)

本文实例为大家分享了C语言实现系统关机注销的具体代码,供大家参考,具体内容如下

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 #include<stdio.h> //printf #include<stdlib.h> //system #include<string.h> //strcat---exit int print() { int n; printf("*****c语言关机程序*****\n"); printf("1:实现十分钟内定时关机\n"); printf("2:立即关闭计算机\n"); printf("3:注销计算机\n"); printf("0:退出系统\n"); printf("请输入你要选择的功能0——3:\n"); scanf("%d",&n); return n; } void main() { system("title c语言关机程序"); //设定dos窗口名称 system("mode con cols=100 lines=100"); //列column,行lines,将dos窗口转化为100行,100列 system("color 0B"); //0(即前者)幕背景颜色,B(即后者)前背景颜色 system("date /T"); //打印系统当前时间 /T作用不太清楚 system("TIME /T"); //打印系统当前日期 char cmd[20]="shutdown -s -t"; //-s关闭计算机,-t延迟时间, char t[5]="0"; int c = print(); getchar(); switch(c) { case 1: printf("您想在多少秒后自动关闭计算机?(0--600)\n"); scanf("%s",t); system(strcat(cmd,t)); //"system -s -t 100"延迟100秒之后关闭计算机 break; case 2: system("shutdown -p"); //仅关闭本地计算机 break; case 3: system("shutdown -l"); //-l:注销当前用户 break; case 0: break; default: printf("error\n"); } system("pause"); //冻结屏幕,便于观察程序的执行结果 exit(0); }

效果:

c语言关机程序(c语言关闭程序命令)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/ZongYinHu/article/details/44875949

如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。