一道C语言编程题,不知道错在哪里,求大神解答!
void qunban() //按班级查询{
struct student
{
char name[20];
char num[12];
float score;
int banji;
}stu[1000];
struct studbanji
{
char name[20];
char num[12];
float score;
int banji;
}stubj[1000];
FILE *fp;
int i=0,k=0,j,pd,sbanji;
float t;
char str1[20],str2[12];
do
{
printf("----------------------------\n");
printf("请输入所查询的班级:\n"); scanf("%d",&sbanji);
if((fp=fopen("stud_score.dat","rb"))==NULL)
{ printf("不能打开文件\n");
exit(0); }
printf("----------------------------\n");
printf("姓名 学号 成绩 班级\n");
do
{ fread(&stu[i],sizeof(struct student),1,fp);
if(sbanji==stu[i].banji)
{
strcpy(stubj[k].name,stu[k].name);
strcpy(stubj[k].num,stu[k].num);
stubj[k].score==stu[k].score;
k++;
}
i++;
}while(!feof(fp));
fclose(fp);
for(i=0;i<k;i++)
for(j=0;j<k-i;j++)
{
if(stubj[j].score<stubj[j+1].score)
{
strcpy(str1,stubj[j+1].name); strcpy(stubj[j+1].name,stubj[j].name);
strcpy(stubj[j].name,str1);
strcpy(str2,stubj[j+1].num); strcpy(stubj[j+1].num,stubj[j].num);
strcpy(stubj[j].num,str2);
t=stubj[j+1].score; stubj[j+1].score==stubj[j].score; stubj[j].score=t;
}
}
for(i=0;i<k;i++)
printf("%s %s %.1f %d\n",stubj[i].name,stubj[i].num,stubj[i].score,stubj[i].banji);
printf("----------------------------\n");
printf("请选择是否继续查询?\n");
printf("1.是 0.否\n");
scanf("%d",&pd); getchar();
}while(pd==1);
}
输入班级后查出来是