#include <SPAN style="FONT-FAMILY: Times New Roman"><stdio.h></SPAN> int main(void) { time_t t; t=time(NULL); printf("The number of seconds since January 1, 1970 is %d/n",t); return 0; }
運行的結果與當時的時間有關,我當時運行的結果是: The Calendar Time now is 1266637045 其中1266637045就是我運行程序時的日歷時間。即從1970年1月1日0時0分0秒到此時的秒數。 第6行中給time函數的參數設置為NULL,可得到具體的秒數。 可將第6行改寫為以下形式: time(&t); 變量t中存放當前的日期和時間(相當于函數返回值);