c語言獲取系統當前時間,本想獲取毫秒的,沒找到方法,直接用微妙了。
獲取的時間爲自 Unix 紀元起至當前的秒數/微秒數。
#include <sys/time.h>
#include <stdio.h>
int main()
{
struct timeval t;
gettimeofday(&t,NULL);
printf("---------------------------->time:%d\n",t.tv_sec); //秒
printf("---------------------------->time:%d\n",t.tv_usec); //微秒(1/1000000秒)
}