我想用c ++搜索二进制文件。但这总是说:“没找到!”。
我的代码:
struct {
char name[20];
char family[20];
char address[100];
char birthday[8];} members[100];
clrscr();
pt=fopen("members.dat","r");
rewind(pt);
char searchName[20];
int found=0;
printf("Please enter search word \n");
scanf("%s", &searchName);
int i=0;
while(!feof(pt)){
i++;
fseek (pt,sizeof(members[i]), 0);
fread(&members[i], sizeof(members[i]), i,pt);
if(searchName==members[i].name){
found=1;
break;}
}
clrscr();
if(found==1){
printf("Found! \n");
printf("%s \n", members[1].name);
printf("%s \n", members[1].family);
printf("%s \n", members[1].address);
printf("%s \n", members[1].birthday);
}
if(found==0){
printf("Not Found");
}
什么是问题?那应该搜索成员结构的名称。
答案 0 :(得分:1)