找不到错啊!!!
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#include"dazuoye.h"
void readFile()
{
int n;
struct stuMessage *head = NULL,*temp;
FILE *inFile;
//char name[20];
//char idnum[8];
//char Clanum[4];
//float grade[10];
inFile = fopen("stuInformation.txt","r");
if(inFile == NULL)
{
printf("文件打开失败,请检查文件是否存在");
exit(1);
}
else
{
head=(struct stuMessage *)malloc(sizeof(struct stuMessage *));
while(fscanf(inFile,"%s %s %s\n",head->name,head->idnum,head->Clanum)!=EOF)
{
head->nextaddr = NULL;
if(firstaddr==NULL)
{
firstaddr=head;
temp=head;
}
else
{
temp->nextaddr=head;
temp=head;
}
head=(struct stuMessage *)malloc(sizeof(struct stuMessage *));
}
}
fclose(inFile);
}
void saveFile()
{
struct stuMessage *temp;
FILE *outFile;
int n;
outFile=fopen("stuInformation.txt","w");
if(outFile==NULL)
{
printf("文件打开失败!");
exit(1);
}
while(firstaddr!=NULL)
{
temp=firstaddr;
firstaddr=firstaddr->nextaddr;
fprintf(outFile,"%s %s %s",temp->name,temp->idnum,temp->Clanum);
for(n=0;n<10;n++)
{
fprintf(outFile,"%f",temp->grade[n]);
free(temp);
}
//fprintf(outFile,"\n",0);
}
fclose(outFile);
}