プロが教えるわが家の防犯対策術!

「今日は何月何日です」とプログラムしたいのですが、わからないので教えてください

A 回答 (2件)

#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);

return 0;
}
    • good
    • 0

#include <stdio.h>



int main(void)
{
printf("今日は何月何日です");
return 0;
}
    • good
    • 4

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!