You have two issues. First, the condition should be while (temp2 != NULL) because you want to include the last node in the search. Second, your search loop doesn't update temp2; the loop is infinite. Compare and contrast:
while(temp2 != NULL) {
if(search == temp2 -> ID) {
cout << "ID\tName\n";
cout << temp2 -> ID << "\t" << temp2 -> name << endl;
decision = 0;
}
temp2 = temp2 -> link;
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401