fork download
  1. #include <stdio.h>
  2. typedef struct date
  3. {
  4. int year;
  5. int month;
  6. int day;
  7. }DATE;
  8. typedef struct student
  9. {
  10. long studentID; /* 学号 */
  11. char studentName[10]; /* 姓名 */
  12. char stuGender; /* 性别 */
  13. DATE birthday; /* 出生日期 */
  14. int score[4]; /* 4门课程的成绩 */
  15. }STUDENT;
  16. int main(void)
  17. {
  18. STUDENT stu1 = {202531116020074, "殷羽辰", 'M', {2007,8,18}, {72,83,90,82}};
  19. STUDENT stu2;
  20. stu2 = stu1; /* 同类型的结构体变量之间的赋值操作 */
  21. printf("stu2:%10ld%8s%3c%6d/%02d/%02d%4d%4d%4d%4d\n",
  22. stu2.studentID, stu2.studentName, stu2.stuGender,
  23. stu2.birthday.year, stu2.birthday.month, stu2.birthday.day,
  24. stu2.score[0], stu2.score[1], stu2.score[2], stu2.score[3]);
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
stu2:202531116020074殷羽辰  M  2007/08/18  72  83  90  82