struct timeval是一个时间结构体, 具体字段分别是秒和微秒, gettimeofday是具体获取时间的函数, 看个程序就明白了:

#include<stdio.h>
#include<sys/time.h>

int main()
{
	struct timeval tv;
	gettimeofday(&tv, NULL);
	printf("second:%d\n", tv.tv_sec);   // second   秒
	printf("micro second:%d\n", tv.tv_usec); // micro second   微秒
	return 0;
}
     结果:

second:1491172737
micro second:693439

     很简单, 就这样。



本文转载:CSDN博客