/* * Sample answer * Author: Programming C teaching group * Date: 2026/10/26 */ #include typedef struct{ int id; /* ID */ char name[12]; /* 名前 */ int year; /* 学年 */ char subject[12]; /* 科目名 */ char grade; /* 成績 */ }CourseRecord; void PrintRecord(CourseRecord); void PrintRecordPtr(CourseRecord *); int main() { CourseRecord studentrecords[2] = { {1319991, "Fukushima", 3, "Literacy", 'B'}, {1319992, "Wakamatsu", 2, "Programming", 'A'} }; printf("構造体の値渡し (PrintRecord)\n"); PrintRecord(studentrecords[0]); PrintRecord(studentrecords[1]); printf("構造体のアドレス値渡し (PrintRecordPtr)\n"); PrintRecordPtr(&studentrecords[0]); PrintRecordPtr(&studentrecords[1]); return 0; } void PrintRecord(CourseRecord s){ printf("%d %12s %d %12s %c\n", s.id, s.name, s.year, s.subject, s.grade); } void PrintRecordPtr(CourseRecord *s){ printf("%d %12s %d %12s %c\n", s->id, s->name, s->year, s->subject, s->grade); }