○現在時刻を取得する ■年月日を求める #include <stdio.h> #include <time.h> int main() { time_t now = time(NULL); struct tm *pnow = localtime(&now); char week[][3] = {"日","月","火","水","木","金","土"}; printf("今日は%2d年%2d月%2d日(%s)です。\n", pnow->tm_year+1900, pnow->tm_mon + 1, pnow->tm_mday, week[pnow->tm_wday]); return 0; } 実行結果 現在の日付が表示されます 今日は2006年12月 1日(金)です。 ■時分秒を求める #include <stdio.h> #include <time.h> int main(){ tim