// 菜单选择1:定时n秒后自动关机voidchoice_01(void){int sec_count;char cmd[30];scanf("%*[^\n]");scanf("%*c");// 清空缓冲区printf("请输入您要定时关机的秒数:");scanf("%d",&sec_count);// 读入定时的秒数sprintf((char*)cmd,"shutdown -s -t %d",sec_count);// cmd定时关机命令...
int main(){ printf("欢迎进入定时关机系统!\n"); getCurrentDate(0); char str[2]; char flag = 1; while(flag){ printf("输入A定时关机,输入C取消定时关机\n"); gets(str); if(strcmp(str,"a")==0) { printf("请输入时间的秒数:\n"); char seconds[10]; while(1){ gets(seconds); if...
1、定时n秒后自动关机 功能演示 代码 // 菜单选择1:定时n秒后自动关机 void choice_01(void) { int sec_count; char cmd[30]; scanf("%*[^\n]");scanf("%*c"); // 清空缓冲区 printf("请输入您要定时关机的秒数:"); scanf("%d", &sec_count); // 读入定时的秒数 sprintf((char*)cmd, ...
整理文件发现以前写的定时关机小程序(Windows下) 1-效果 2-程序 #include<stdio.h>#include<stdlib.h>#include<string.h>intmain(){//界面printf("---自动关机小程序---\n");printf("您想在几分钟后关机?请输入正整数:");//定义变量unsignedlonglongsecond;unsignedintminutes;charcharsecond[100]={};cha...
我们输入返回值为0的返回函数:return 0;我们定时关机的小程序到这一步就编写完了。编译运行程序 1 接下来我们点击编译,让计算机将我们编写的程序编译成小程序 2 保存类型选择为.c 3 这个就是我们编写的定时关机小程序了,双击运行试试吧!注意事项 代码中的各种符号都是要在英文输入法的状态下输入的哦!
case 1:printf("您想在多少分钟后自动关闭计算机?\n"); cueTone();scanf_s("%d", &xs); z = xs * 60;_itoa(z, ht, 10); system(strcat(cmd, ht)); printf("按y返回主菜单,按任意键退出程序\n"); cueTone();scanf_s("%s", &ss, 2);if (ss == 'y') { cc++; printf("请重新...
system("title C语言定时关机程序");//设置cmd窗口标题system("mode con cols=50 lines=30");//窗口设置system("color 84");//可以任意设定颜色system("date /T");system("TIME /T"); printf("--- C语言定时关机程序 ---n");printf("1.实现10分钟内的定时关闭计算机n");printf("2.立即关闭计算机...
步骤一,创建一个新工程。在顶部菜单选择"文件"->"新建"->"Win32 Console Application",取一个易于识别的工程名字,位置选在方便查找的文件夹。新建编程工程文件并命名 接下来,为了存放C语言源程序,再次点击"文件"->"新建"->"C++ Source File",为文件命名,至此,准备工作基本完成。通过这样的...
#include #include int main(){ system( title 定时关机程序V1.0 ); system( color 1F ); system( mode con: cols=30 lines=15 ); char cmd[20]= shutdown -s...
C语言编写简单的定时关机程序 写一个定时关机的小程序,可以立即关闭计算机,也可以一段时间后关闭计算机。 这里主要考察system()命令。 代码实现: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() char cmd20="shutdown -s -t ";...