I need to get the current time in a "HH:MM:SS"-format into a character array (string) so I can output the result later simply with a printf("%s", timeString);
I'm pretty confused on the timeval
and time_t
types btw, so any explanation would be awesome:)
EDIT: So I tried with strftime etc, and it kinda worked. Here is my code:
time_t current_time;
struct tm * time_info;
char timeString[8];
time(¤t_time);
time_info = localtime(¤t_time);
strftime(timeString, 8, "%H:%M:%S", time_info);
puts(timeString);
But the output is this: "13:49:53a??J`aS?"
What is going on with the "a??J`aS?" at the end?