#include <time.h>
time_t time( time_t *time );
函数返回当前时间,如果发生错误返回零。如果给定参数 time ,那么当前时间存储到参数 time 中。
#include <time.h> #include <stdio.h> #include <dos.h> int main(void) { time_t t; t = time(NULL); printf("The number of seconds since January 1, 1970 is %ld",t); return 0; }
输出结果:
The number of seconds since January 1, 1970 is 1657812995