C time
ナビゲーションに移動
検索に移動
C 日付と時刻
時刻はtime_t型を利用して処理される。すべてのUnix Systemは Greenwich 標準時(GMT Greenwich Mean Time) の 1970年1月1日0時を日付と時刻の起点としている。(epochの起点)
time
- 低水準の時刻の値を取得するには、time関数を利用する。
- epochの起点からの経過秒数を取得する。
- tlocがnull pointerでなければ、結果を書き込む
- #include <time.h>
- time_t time(time_t *tloc);
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>#include <unistd.h>
- int main() {
- time_t the_time; int i;
- for(i=0; i<10; i++) {
- the_time = time((time_t*)0);
- printf("time %ld\n", the_time);
- sleep(2);
- }
- exit(0);
- }
この本からの覚書。
© 2006 矢木浩人