Search Using While Loop/ Infinitite loop problem

I am a bit stuck on this one. My loop gets stuck in an infinite loop when it
finds the 'team'. Here's the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

//overlaoded operator
bool operator == ( const FootballTeam& team )
	{ if ( city == team.city ) return true ; return false; }

//search for team
void searchTeam ( List<FootballTeam>& display )
{
	FootballTeam team;
	string input;

	bool found = false;

	cout<<"Enter the city of the team to display: ";
	getline ( cin, input);

	while ( input != "N/A" )
	{
		team.city = input; 

		found = display.getMember(team);

		if(found)
		{
			cout << team;
		}
		else
		{
			cout<<"That team is not found \n";
			cout<<"Enter city again: ";
			getline ( cin , input ); 
			cout << endl;
		}

		cout << endl;
	}
	
}


Any ideas to why its doing this? Any help is appreciated!
Last edited on
because "input" variable never changes after you found the team, so it would never became equals "N/A". Either rewrite program logic, or insert break; statement after cout << team; on line 25.
Topic archived. No new replies allowed.