2012年11月15日
摘要: 使用C语言编写程序需要获得当前精确时间(UNIX到现在的时间),或者为执行计时,可以使用gettimeofday()函数。它的[1]: #include <sys/time.h> int gettimeofday(structtimeval*tv, struct timezone *tz); 其参数tv是保存获取时间结果的结构体,参数tz用于保存时区结果(若不使用则传入NULL即可)。 结构体timeval的定义为: struct timeval { long tv_sec; // 秒数 long tv_usec; // 微秒数 } 它获得的时间精确到微秒(1e-6 s)量级... 阅读全文
posted @ 2012-11-15 16:25 Sparkjin 阅读(470) 评论(0) 推荐(0) 编辑