代码如下
#include <stdio.h>
#include <stdlib.h>
struct student //定义一个结构体,存储每个学生的成绩姓名等信息,可以包含其他的信息,视需要增加
{
int score;
char *name;
};
struct student* initStus(int length) //初始化,登记学生的姓名、信息
{
int i;
struct student *p = (struct student *)malloc(length*sizeof(struct student));
for(i=0;i<length;i++)
{
printf("请输入姓名:");
p->name = (char *)malloc(128);
scanf("%s",(p->name));
printf("请输入分数:");
scanf("%d",&(p->score));
p++;
}
return p-length;
}
void printMes(struct student *p,int length) //将登记好的信息打印出来
{
int i;
for(i=0;i<length;i++)
{
pri