c语言fwrite函数变了,C语言用fwrite函数写入错误怎样解决?

void ReadInfo()

{

FILE *fp;

int i;

if ((fp=fopen("Database.txt","rb+"))==NULL)

{

printf("不能打开文件!\n");

return;

}

if (fread(&count,sizeof(int),1,fp)!=1)

{

count=-1;

}

else

{

for(i=0;i

{

fread(&record[i],sizeof(struct student),1,fp);

}

}

fclose(fp);

}

void WriteInfo()

{

FILE *fp;

int i;

if ((fp=fopen("Database.txt","wb+"))==NULL)

{

printf("不能打开文件!\n");

return;

}

if (fwrite(&count,sizeof(int),1,fp)!=1)

{

printf("写入文件错误!\n");

}

for (i=0;i

{

if (fwrite(&record[i],sizeof(struct student),1,fp)!=1)

{

printf("写入文件错误!\n");

}

}

fclose(fp);

}

你可能感兴趣的:(c语言fwrite函数变了)