求大神看看我的错误在哪?fwrite文件写入后无端多出一条信息
代码:struct basic 结构体已经定义为SBA
#define BUSIN_PATH "E:\\个人程序\\新建文件夹\\Business_input.dat"
FILE *bufp;
if((bufp=fopen(BUSIN_PATH,"rb+"))==NULL)
{
printf("\t>>>cannot open file");
system("pause");
}
int N=File_size(bufp,sizeof(SBU),"成绩信息");
SBU*b=(SBU*)malloc(N*sizeof(SBU));
fread(b,sizeof(SBU),N,bufp);
rewind(bufp);
for(int i=0;i<N;i++)
{
printf("%11s\t%11s\t%.1f\t%d\n",b[i].num,b[i].c_num,b[i].score,b[i].unpass);
}
//rewind(bufp);
printf("请输入学号和课程编号进行修改:");
char str[11],strc[11];
scanf("%s%s",str,strc);
fflush(stdin);
for(int i=0;i<N;i++)
{
if((strcmp(str,b[i].num)==0)&&(strcmp(strc,b[i].c_num)==0))
{
printf("学号%s编号%s课程进行以下修改\n",b[i].num,b[i].c_num);
printf("请依次输入:成绩 是否补考\n");
scanf("%f%d",&b[i].score,&b[i].unpass);
printf("第%d条信息已修改成功\n",i);break;
}
}
fwrite(b,sizeof(SCO),N,bufp);
fclose(bufp);
free(b);
system("pause");