printf("Input Second:"); if (scanf("%d", &second) != 1 || second<0 || second>59) { puts("Input second error!"); getchar(); exit(0); } }
/* * Function Name: NextSec() * Describle: Count the next second by the current time * Paramete; void * ReturnValue: void */ void NextSec(void) { if (++second == 60) { second = 0; minute++; } if (minute == 60) { minute = 0; hour++; } if (hour == 24) { hour = 0; day++; } if (day == Amonth[leap][month]+1) { day = 1; month++; } if (month == 13) { month = 1; year++; }
printf("The next second is %d-%d-%d %d:%d:%d\n\n", year, month, day, hour, minute, second); }