#include <stdio.h>
#include <sys/time.h>
int main()
{
float time;
struct timeval tv;
gettimeofday( &tv, NULL );
time = tv.tv_sec + ( tv.tv_usec / 1000000.0 );
printf( "time: %f\n", time );
return 0;
}
Running binary generated by this code repeatedly, I tend to get the same time value:
$ ./a.out
time: 1348059520.000000
$ ./a.out
time: 1348059520.000000
$ ./a.out
time: 1348059520.000000
This happens until several seconds later at which I get an updated time value.