English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Libreria standard C - <time.h>
C 库函数 time_t time(time_t *seconds) 返回自纪元 Epoch(1970-01-01 00:00:00 UTC)起经过的时间,以秒为单位。如果 seconds 不为空,则返回值也存储在变量 seconds 中。
以下是 time() 函数的声明。
time_t time(time_t *t)
seconds -- 这是指向类型为 time_t 的对象的指针,用于存储 seconds 的值。
以 time_t 对象返回当前日历时间。
以下示例演示了 time() 函数的使用方法。
#include <stdio.h> #include <time.h> int main () { time_t seconds; seconds = time(NULL); printf("Ore dal 1970-01-01 = %ld\n", secondi/3600); return(0); }
Compiliamo e eseguiamo il programma sopra, il che produrrà il seguente risultato:
Ore dal 1970-01-01 = 402711