#include<stdio.h>
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}};
void main()
{
int i;
struct student *ps;
printf("Num\tName\t\t\tSex\tAge\t\n");
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);
//for(i=0;i<5;i++)
//printf("%d\t%d\t\n",stu[i].num,stu[i].age);
}
/*用指针变量输出结构体数组元素*/
最新推荐文章于 2023-08-29 13:10:40 发布