#include<stdio.h>
#define N 5
void main()
{
struct st
{char ch[10];
long int xh;
float score;
}a[N];
FILE *fp;
fp=fopen("legend.txt","r");
for (int i=0;i<N;i++)
fscanf(fp,"%s,%Ld,%f",&a[i].ch,&a[i].xh,&a[i].score);
struct st *pt;
pt=a;
for(pt=a;pt<a+N;pt++)
{ if(pt->ch=="B")
printf("%s,%Ld,%4.1f",pt->ch,pt->xh,pt->score);
else break;
}
fclose(fp);
}
文件如下:
A,980102,80.5
B,980103,90.0
C,980104,75.5
D,980105,85.0
E,980106,95.0
请问为什么不能读出B及其同组数据?谢谢