gettime、settime
dos.h:インデックス への移動
ヘッダー ファイル
dos.h
カテゴリ
日付/時刻ルーチン
プロトタイプ
void gettime(struct time *timep);
void settime(struct time *timep);
説明
システム時刻の取得および設定を行います。
gettime は、timep が指している time 構造体の中にシステムの現在の時刻を書き込みます。
- settime は、システム時刻を timep が指している time 構造体の値に設定します。
time 構造体は次のように定義されています。
struct time {
unsigned char ti_min; /* minutes */
unsigned char ti_hour; /* hours */
unsigned char ti_hund; /* hundredths of seconds */
unsigned char ti_sec; /* seconds */
};
戻り値
ありません。 無効な引数を渡した場合、時刻は変更されず、errno は EINVAL(無効な引数)に設定されます。
例
#include <stdio.h>
#include <dos.h>
int main(void)
{
struct time t;
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d\n",
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
return 0;
}