AB下载管理器完全指南:让你的下载速度飞起来
2026/1/16 6:30:22
time()函数返回自纪元(epoch)以来经过的秒数,以此表示当前时间。如果参数t不为NULL,该函数还会将当前时间写入该指针。出现错误时,函数返回 -1(转换为time_t类型),并适当地设置errno。唯一可能的错误是EFAULT,表示t是无效指针。
示例代码如下:
#include <stdio.h> #include <time.h> int main() { time_t t; printf ("current time: %ld\n", (long) time (&t)); printf ("the same value: %ld\n", (long) t); return 0; }gettimeofday()函数扩展了time()函数,提供了微秒级的分辨率。
#include <sys/time.h> int gettimeofday (struct timev