求教一个关于从文件中循环读出数组的问题 ,第5.6行那里有问题,但不知道咋弄
void cx(int z) { int a=0; char name1[8];
struct student stu1;
printf("\n请输入你要查找的学生名字:");
scanf("%s",name1);
if((fp=fopen(txt,"rt"))==NULL)
{printf("\n打开文件错误!"); }
while(!feof(fp))
{
fscanf(fp,"%d %s %.2f %.2f %.2f ",stu1.num,stu1.name,stu1.math,stu1.chinese,stu1.english);
if(strcmp(name1,stu1.name)==0)
{ printf("\n 学号:%d",stu1.num);
printf("\n 姓名:%s",stu1.name); printf("\n 数学:%.2f",stu1.math); printf("\n 语文:%.2f",stu1.chinese); printf("\n 英语:%.2f",stu1.english); a=1; Sleep(3000); break; }}
if(!a) printf("\n查无此人!");
Sleep(3000); fclose(fp);
caidan(); }