14、/*Use pointer variables to output the elements of the structure array.*/
struct student
{
int num;
char *name;
char sex;
int age;
}stu[5]={{1001,”lihua”,’F’,18},{1002,”liuxing”,’M’,19},{1003,”huangke”,’F’,19},{1004,”fengshou”,’F’,19},{1005,”Wangming”,’M’,18}};
main()
{int i;
struct student *ps;
printf(“Num \tName\t\t\tSex\tAge\t\n”);
/*Use pointer variables to output the elements of the structure array.*/
for(ps=stu;ps<stu+5;ps++)
printf(“%d\t%-10s\t\t%c\t%d\t\n”,ps->num,ps->name,ps->sex,ps->age);
/*Use array subscript method to output the student number and age of the structure array.*/
for(i=0;i<5;i++)
printf(“%d\t%d\t\n”,stu[i].num,stu[i].age);
}