从该文件读出学生信息数据,按成绩从高到底排序,并输出其中成绩次高者的所有数据。
#include <stdio.h>
#include <stdlib.h>
typedef struct student
{
char number[20];
char name[20];
char sex[10];
char birth[20];
char province[20];
int score;
struct student *next;
}student;
void getSecond(student *s[],int sn);
void sort(student *s[],int sn);
int main()
{
FILE* fd;
int flag = 0;
int sn = 10;//读取前面十个学生的信息
student * s[sn];
//申请内存空间
for(;flag<sn;flag++)
{
s[flag] = (student *) malloc(sizeof(student));
}
//打开文件
if((fd = fopen("d:\g.txt","r"))==NULL)
{
printf("文件读取失败.\n");
return 0;
}
printf("文件读取成功.\n");
//读取文件
for( flag = 0; flag < sn; flag++)
{
fscanf(fd,"%s%s%s%s%s%d",s[fl