time 返回系统的当前日历时间

头文件

#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