Hey guys, I'm back again...
Need help trying to figure out how to fix this code. It's about checking an array to another array. The problem that I am having is that when I have two address name david and david3, david3 comes up with the info perfectly, but the david address comes up with info but blank. Or even if I have one address named david3, and david name is searched, it'll come up with info but blank.
Can you help me revise my code to prevent this error?
It works, but it doesn't work for very very very similar names (ie: david/david3 or kumar/kumar2, etc...)
Thanks
Code:
printf("\n***********Search an address************");
printf("\nEnter nickname to search: ");
scanf("%s", search);
j=0;
for(i=0; i< M-1; i++)
{
while(search[j] == name[i][j] && search[j] != '\0' && name[i][j] != '\0')
j++;
if(search[j] == '\0' && name[i][j] == '\0')
{
are_equal = true;
index_temp = i;
break;
}
else if(search[0] == 0 && name[i][0] == 0)
continue;
else
are_equal = false;
}
if(are_equal == false)
{
printf("\nNickname does not exist, address not found");
goto end;
}
if(are_equal = true)
{
*****REST OF THE CODE****