一个定时关机的小程序!有点错误,求大神指教!
#include<stdio.h>main()
{int i;
void set_time_shutdown();
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
n:
printf(" 请选择关机时间或自己设定关机时间 \n");
printf("~~~~~~~~~~~请选择~~~~~~~~~~~~~~~~~\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("1、0:00:00关机!\n");
printf("2、1:00:00关机!\n");
printf("3、2:00:00关机!\n");
printf("4、3:00:00关机!\n");
printf("5、4:00:00关机!\n");
printf("6、5:00:00关机!\n");
printf("7、6:00:00关机!\n");
printf("8、7:00:00关机!\n");
printf("9、自己设定关机时间!\n");
printf("0、取消定时关机!\n");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("请选择:");
scanf("%d",&i);
switch(i)
{
case 1: system("at 18:54 shutdown -s");break;
case 2: system("at 1:00 shutdown -s");break;
case 3: system("at 2:00 shutdown -s");break;
case 4: system("at 3:00 shutdown -s");break;
case 5: system("at 4:00 shutdown -s");break;
case 6: system("at 5:00 shutdown -s");break;
case 7: system("at 6:00 shutdown -s");break;
case 8: system("at 7:00 shutdown -s");break;
case 9: set_time_shutdown();break;
case 0: system("shutdown -a");break;
default:printf("输入错误!请重新输入!");goto n;
}
}
void set_time_shutdown()
{
char a[2];
char b[2];
char buff[2];
char bull[2];
printf("请输入关机的小时数!(格式为1、2、3、4......)\n");
printf("请输入:");
scanf("%c",&a);
fprintf(buff,"%c:",a);
printf("\n");
printf("请输入关机的分钟数!(格式为01、02、03、04......)\n");
printf("请输入:");
scanf("%c",&b);
fprintf(bull,"%c:",b);
system("at buff:bull shutdown -s");
}
求教,为什么选择9的时候,输入小时那有错误!求高手指教!