I am trying to convert time string into time format in C on windows. As i just have hour, minutes and seconds in my string, so tried to parse the string using sscanf into time format and then use mktime. But somehow its not converting it into time format. To check, i tried to print the converted time into string back. The code looks like:
struct tm tm;
char time_buffer[100];
int hh, mm;
float ms;
time_t time_value;
char *timestamp = {"16:11:56.484"};
sscanf(timestamp, "%d:%d:%f", &hh, &mm,&ms);
tm.tm_hour =hh;
tm.tm_min = mm;
tm.tm_sec = ms*1000;
tm.tm_isdst = -1;
time_value = malloc(100*sizeof(char));
time_value = mktime(&tm);
if (time_value==-1)
printf ("unable to make time");
strftime(time_buffer, sizeof(time_buffer), "%c", &tm);
printf(time_buffer);