This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
int main(void) | |
{ | |
time_t timer; | |
struct tm *t_st; | |
/* 現在時刻の取得 */ | |
time(&timer); | |
/* 現在時刻を文字列に変換して表示 */ | |
printf("現在時刻: %s\n", ctime(&timer)); | |
/* 現在時刻を構造体に変換 */ | |
t_st = localtime(&timer); | |
printf("月: %d\n",t_st->tm_mon+1); /* 月は+1 */ | |
printf("日: %d\n",t_st->tm_mday); | |
printf("時: %d\n",t_st->tm_hour); | |
printf("分: %d\n",t_st->tm_min); | |
printf("秒: %d\n",t_st->tm_sec); | |
if( t_st->tm_hour == 11 && t_st->tm_min > 32 ) return 1; | |
if( t_st->tm_hour == 12 && t_st->tm_min < 28 ) return 1; | |
return 0; | |
} |
0 件のコメント:
コメントを投稿