Okay so here is what i have. It is suppose to search both male names and female names. But if it finds one it displays that one and not the other (Some names work for boys and girls). What should i do to make it re' search through the list and find the other names. Thanks.
EDIT: i fixed it all i had to do was have it repoint to the top of the list, stupid me!Code:while (!terminate) { cout << "Enter a name (First letter must be a Capital) or type 'done' to finsh searching.\nName: "; string target; cin >> target; tempPtr = topList; while ((tempPtr->boysName != target) && (tempPtr->link != NULL)) { tempPtr = tempPtr->link; } // If done is typed a user is finished and program terminates. if (target == "done") terminate = true; else if (tempPtr->boysName == target) { cout << target << " is ranked " << tempPtr->rank << " among boys' names.\n" << endl; } else cout << "Name not found in Babynames2004 database" << endl; while ((tempPtr->girlsName != target) && (tempPtr->link != NULL)) { tempPtr = tempPtr->link; } // If done is typed a user is finished and program terminates. if (target == "done") terminate = true; else if (tempPtr->girlsName == target) { cout << target << " is ranked " << tempPtr->rank << " among girls' names.\n" << endl; } else cout << "Name not found in Babynames2004 database\n" << endl; }



LinkBack URL
About LinkBacks


