记录一下,获取当前的时间的秒数和微秒数本方法需要用到gettimeofday()函数,引入的头文件 sys/time.h 。
说明
int gettimeofday (struct timeval * tv, struct timezone * tz)
返回值:该函数成功时返回0,失败时返回-1
参数
struct timeval{
long tv_sec; //秒
long tv_usec; //微秒
};
struct timezone
{
int tz_minuteswest; //和Greenwich 时间差了多少分钟
int tz_dsttime; //日光节约时间的状态
};