1
0

c9-6.c 523 B

12345678910111213141516
  1. #include <stdio.h>
  2. struct student
  3. {int num;
  4. char name[20];
  5. char sex;
  6. int age;
  7. };
  8. struct student stu[3]={{10101,"Li Lin",'M',18},{10102,"Zhang Fun",'M',19},{10104,"Wang Min",'F',20}}; // 定义结构体数组并初始化
  9. int main()
  10. {struct student *p; //定义指向struct student结构体的数组
  11. printf(" No. Name sex age\n");
  12. for (p=stu;p<stu+3;p++)
  13. printf("%5d %-20s %2c %4d\n",p->num, p->name, p->sex, p->age);
  14. return 0;
  15. }