当前位置: 代码迷 >> 综合 >> c库函数-time()
  详细解决方案

c库函数-time()

热度:19   发布时间:2023-09-27 14:57:14.0

c库函数time_t time(time_t*seconds)返回自纪元Epoch(1970-01-01 00:00:00UTC)起经过的时间,以秒为单位

如果seconds不为空,则返回值也存储在变量seconds中

下面是time()函数的声明

time_t time(time_t *t)


参数

seconds,这是指向类型为time_t的对象的指针,用来存储seconds的值


返回值

以time_t对象返回当前日历时间


实例

#include <stdio.h>

#include <time.h>

int main()

{

time_t seconds;

seconds=time(NULL);

printf("当前时间",ctime(&curtime));

return 0;

}


将显示结果

小时数=373711

  相关解决方案