int SaveStudent(Student *Q)
{
int i=0;
Student *p;
FILE *fp;
char open[20];
p=Q->next;
printf("请输入文件路径:");
scanf("%s",open);
if((fp=fopen(open,"w+"))==NULL)
{
printf("打开失败!");
return 0;
}
//fprintf(fp,"%s","学号\t姓名\t性别\t语文\t英语\t数学\t均分\n");
while(p!=NULL&&i<amount)
{
i++;
// fwrite(p,sizeof(Student),1,fp);
fprintf(fp,"%d\t%s\t%s\t%d\t%d\t%d\t%d\n",p->number,p->name,p->sex,p->Chinese,p->English,p->Match,p->average);
p=p->next;
}
fprintf (fp,"\0");
fclose(fp);
return 1;
}
void LoadStudent()
{
int flag=1;
char FileName[30];
Student *p;
FILE *fp=NULL;
//char *buffer;
printf("name:");
scanf("%s",FileName);
//buffer=(char *)malloc(255);
if((fp=fopen(FileName,"r+"))!=NULL)
{
fscanf(fp,"学号\t姓名\t性别\t语文\t英语\t数学\t均分\t\n");
printf("|学号\t|姓名\t|性别\t|语文\t|英语\t|数学\t|均分\t|\n");
while (!feof(fp))
{
p=(Student*)malloc(sizeof(Student));
fscanf(fp,"%d\t%s\t%s\t%d\t%d\t%d\t%d",&p->number,p->name,&p->sex,&p->Chinese,&p->English,&p->Match,&p->average);
printf("|%d\t|%s\t|%s\t|%d\t|%d\t|%d\t|%d\t|\n",p->number,p->name,p->sex,p->Chinese,p->English,p->Match,p->average);
getch();
}
}
else
printf("调出失败!");
fclose(fp);
}
这是我对论坛上那个学生信息管理系统不能实现的2个函数的修改,我在DEV 4.0下是可以实现其功能的,看对楼主有什么帮助不