You are viewing a single comment's thread. Return to all comments →
char* timeConversion(char* s) { unsigned int hour; unsigned int minute; unsigned int second; char format[2];
sscanf(s,"%2u:%2u:%2u%s", &hour, &minute, &second, format); s[2] = '\0'; hour = atoi(s); if (strcmp(format, "PM") == 0) { if (hour!= 12) hour += 12; } else { if (hour == 12) hour = 0; } size_t len = strlen(s); char *clock = malloc(len*sizeof(char)); sprintf(clock, "%.2d:%.2d:%.2d", hour, minute, second); return clock; return NULL;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
char* timeConversion(char* s) { unsigned int hour; unsigned int minute; unsigned int second; char format[2];
}