Reputation: 474
Somebody helped me that i should change the char[]
to string
, but I am still having problem comparing the strings imputed by the user. I am not sure if I have to use fstream
or something else. getline
did not really help me since it shows errors depending on what it is inside the getline.
void search (competitor competitors[], int broi)
{
string country;
string name;
char choice;
bool flag;
do{
cout << "\n\n Input Country: " << endl;
fstream country;
cout << " Input name: " << endl;
fstream name;
flag = false;
for(int i=0; i<count; i++)
{
if( country==competitors[i].country && name==competitors[i].name)
{
cout << "found one" << endl;
flag = true;
}
}
if (flag == false)
cout << " New search (Y/N)?: ";
cin >> izbor;
}while(choice == 'Y' || choice == 'y');
}
Upvotes: 0
Views: 134
Reputation: 299979
fstream country;
This declares a new variable named country
of type fstream
. Probably not what you want.
You should try:
getline(std::cin, country);
instead. And you have the same issue with name
.
Also:
flag = true;
better call break
directly.
And:
cin >> izbor;
should probably be: cin >> choice;
Upvotes: 4