有人帮助我,我应该将其更改char[]
为string
,但我在比较用户输入的字符串时仍然遇到问题。我不确定我是否必须使用fstream
或其他东西。getline
并没有真正帮助我,因为它根据 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');
}