gettimeofday(struct timeval *tv, struct timezone *tz)函數
功能:獲取當前精確時間(Unix時間)
其中:
timeval為時間
truct timeval{
long tv_sec; // 秒數
long tv_usec; // 微秒數
}
timezone為時區
#include<stdio.h> #include<sys/time.h> int main(){ struct timeval tv; gettimeofday(&tv,NULL); printf("%d,%d\n",tv.tv_sec,tv.tv_usec); return 0; }