You didn't find the othernames
from the beginning to end to compare people
every time, so you need to replace
for (i = 0; i < n; i++) {
if (strcmp(othernames[i], people[i].name) == 0) {
printf("%s=%i
", people[i].name, people[i].number);
}
else {
printf("Not found
");
}
}
to
bool found = false;
for (i = 0; i < n; i++) {
for ( j = 0 ; j < n ; j++ ) {
if (strcmp(othernames[j], people[i].name) == 0) {
printf("%s=%i
", people[i].name, people[i].number);
found = true;
}
}
}
if ( found == false ) printf("Not found
");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…