/* 構造体 strucr Potter を宣言し、実行例のように、キーボードから洋書の題名 (原題)、 日本語の題名、発行年を入力し、ディスプレイに表示するプ ログラムを作成せよ。 */ #include // 構造体 Potter の定義 typedef struct Potter { char title[100]; // 英語の題名(文字列) char jptitle[100]; // 日本語の題名(文字列) int year; // 発行年(整数) } Potter; int main(void) { Potter potter1; printf("英語のタイトルを入力してください。\n"); // [注意] スペースを含む文字列を読み込むため "%[^\n]" を使用しています scanf(" %[^\n]", [ ア ]); printf("日本語のタイトルを入力して下さい。\n"); scanf(" %[^\n]", [ イ ]); printf("発行年を入力して下さい。\n"); scanf("%d", [ ウ ]); // 結果の表示 printf("\n"); printf("English Title : %s\n", [ ア ]); printf("邦訳 : %s\n", [ イ ]); printf("発行年 : %d\n", [ エ ]); return 0; } /* 実行例 English Title : Ban This Book 邦訳 : 貸出禁止の本をすくえ! 発行年 : 2017 */