How come this is not returning the desired outcome?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv) {
time_t c_time, a_time;
char buffer[256];
struct tm a_time_struct;
printf("Enter the time in which you want to wake up.\n");
printf("In this format: (MM DD YYYY hh mm).\n");
fgets(buffer, sizeof buffer, stdin);
sscanf(buffer, "%i %i %i %i %i", &a_time_struct.tm_mon, &a_time_struct.tm_mday, &a_time_struct.tm_year
,&a_time_struct.tm_hour, &a_time_struct.tm_min);
printf("%i = mon, %i = day, %i = year, %i = hour, %i = min.\n", a_time_struct.tm_mon, a_time_struct.tm_mday, a_time_struct.tm_year, a_time_struct.tm_hour, a_time_struct.tm_min);
/* . . . */
return 0;
}
Here is my test run.
Enter the time in which you want to wake up.
In this format: (MM DD YYYY hh mm).
03 09 2004 10 56
3 = mon, 0 = day, 9 = year, 2004 = hour, 10 = min.