#include <stdio.h>
#include <string.h>
/* 構造体hitoを定義 */
struct hito {
int age; /* 年齢 */
char blood[3]; /* 血液型 */
};
void main(void) {
/* hito型変数masasiを宣言 */
struct hito masasi;
/* hito型構造体のポインタ変数pを宣言 */1
struct hito* p;
/* 構造体masasiの先頭アドレスをポインタ変数pに代入 */2
p = &masasi;
/* まさし君のプロフィールを設定 */
p->age = 10;3
strcpy(p->blood, "A");3
/* 年齢、血液型表示 */
printf("まさしくんのプロフィール\n");
printf("年齢:%d歳\n", p->age);4
printf("血液型:%s型\n", p->blood);4
} |