I need to get the time at certain intervals of my programme.
The problem is I need to get the time a lot, so I also the amount of nano seconds, or all the times are the same.
Im currently using the method below which prints the value in hh:mm:ss
The problem is I need to get the time a lot, so I also the amount of nano seconds, or all the times are the same.
Im currently using the method below which prints the value in hh:mm:ss
Code:
time_t now;
struct tm ts;
char buf[80];
// Get the current time
time(&now);
// Format and print the time, "hh:mm:ss "
ts = *localtime(&now);
strftime(buf, sizeof(buf), "%H:%M:%S", &ts);
printf("%s\n", buf);