現在の日付を次の形式で印刷する必要があります。今日は水曜日から2012年9月7日です。構造体を使用する必要があることはわかっています。
struct tm* time_info;
これはstrftime()を使用して簡単に実行できますが、strftime()を使用せず、printfステートメントを使用して構造体のメンバーを直接抽出する必要があります。正しく動作させることができないようです。手がかりはありますか?これが私の現在のコードです:
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
#include <stdlib.h>
/* localtime example */
#include <stdio.h>
#include <time.h>
int main (void)
{
time_t t;
char buffer[40];
struct tm* tm_info;
time(&t);
tm_info = localtime(&t);
strftime(buffer, 40, " Today is %A - %B %e, %Y", tm_info);
puts(buffer);
return 0;
}
それ以外の
strftime(buffer, 40, " Today is %A - %B %e, %Y", tm_info);
私は欲しい
printf("Today is %s, struct members info in the correct format);