|
You can use the gettimeofday() and the timeval structure to achieve what you want.
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
int
main(void)
{
char buf[30];
struct timeval tv;
time_t ct;
int ms;
gettimeofday(&tv, NULL);
ct = tv.tv_sec;
strftime(buf, 30, "%m/%d/%y %T.", localtime(&ct));
ms = (tv.tv_usec % 1000000) / 1000;
printf("Timestamp: %s%d\n", buf, ms);
}
|