How do I get a microseconds timestamp in C?
I\'m trying to do:
struct timeval tv;
gettimeofday(&tv,NULL);
return tv.tv_usec;
Bu
struct timeval contains two components, the second and the microsecond. A timestamp with microsecond precision is represented as seconds since the epoch stored in the tv_sec field and the fractional microseconds in tv_usec. Thus you cannot just ignore tv_sec and expect sensible results.
If you use Linux or *BSD, you can use timersub() to subtract two struct timeval values, which might be what you want.