小白教程
所有教程
关于
Search
172.71.254.227
172.71.254.227
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“C function time”的源代码
本页内容
下一节:
C_function_ctime
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:time_t time(time_t *time);}}[[Category:cpp date time|1]] = C 库函数 - time() = [[c standard library time h|C 标准库 - <time.h>]] == 描述 == C 库函数 '''time_t time(time_t *seconds)''' 返回自纪元 Epoch(1970-01-01 00:00:00 UTC)起经过的时间,以秒为单位。如果 '''seconds''' 不为空,则返回值也存储在变量 '''seconds''' 中。 == 声明 == 下面是 time() 函数的声明。 <pre> time_t time(time_t *seconds) </pre> == 参数 == * '''seconds''' -- 这是指向类型为 time_t 的对象的指针,用来存储 seconds 的值。 == 返回值 == 以 time_t 对象返回当前日历时间。 下面的实例演示了 time() 函数的用法。 <sample title="" desc="" lang="c" hererun="1"> #include <stdio.h> #include <time.h> int main () { time_t seconds; seconds = time(NULL); printf("自 1970-01-01 起的小时数 = %ld\n", seconds/3600); return(0); } </sample> 让我们编译并运行上面的程序,这将产生以下结果: <pre> 自 1970-01-01 起的小时数 = 373711 </pre> [[c standard library time h|C 标准库 - <time.h>]]
返回至“
C function time
”。
下一节:
C_function_ctime