简单的复习一下结构体数组的相关知识(见代码)
#include <stdio.h>
#define MAX 2
struct Student //定义结构体
{
char name[20];
char num[20];
char Class[20];
int score;
}peer[MAX],*p; //结构体数组和指针
int main()
{
int i,j;
for(i=0;i<MAX;i++) //给结构体数组存值
{
printf("Please input peer %d name \\n num \\n class \\n score \\n :\n",i+1);
scanf("%s",&peer[i].name);
scanf("%s",&peer[i].num);
scanf("%s",&peer[i].Class);
scanf("%d",&peer[i].score);
}
printf("inversion output:");
for(p=peer+MAX-1;p>=peer;p--) //用指针倒置输出结构体数组
{
printf("\n%s %s %s %d",p->name,p->num,p->Class,p->score);
}
return 0;
}