struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
int main(int argc,char * argv[]){
struct timeval tv;
while(1){
gettimeofday(&tv,NULL);
printf("time %u:%u/n",tv.tv_sec,tv.tv_usec);
sleep(2);
}
return 0;
}struct timespec
{
time_t tv_sec;
long int tv_nsec;
};
版权声明:本文为博主原创文章,未经博主允许不得转载。
struct timeval 和 struct timespec
原文:http://blog.csdn.net/u014338577/article/details/47072765