转自:https://gist.github.com/sevko/d23646ba07c77c15fde9
Get the current time in microseconds in C.
程序:
#include <sys/time.h>
/**
* Returns the current time in microseconds.
*/
long getMicrotime(){
struct timeval currentTime;
gettimeofday(¤tTime, NULL);
return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}
运行环境:
linux
本文介绍了一个C语言函数,用于获取当前时间的微秒精度。通过使用sys/time.h库中的gettimeofday函数,该代码段能够准确地返回当前时间戳,精确到微秒。
1024

被折叠的 条评论
为什么被折叠?



