私は、このコードの断片で何が間違っているかを調べようとしています。これは、エラーを言う:行の[Error] no match for 'operator>>' in 'inputData >> Player[i].AthleteType::firstName
':"no match for '演算子>>はコード内で何を意味しますか?
inputData >> Player[i].firstName;
誰かがこれが何を意味するのかを教えてもらえますか?また、これが次のようなファイルからデータを読み取る正しい方法である場合:
Peter Gab 2653 Kenya 127
Usian Bolt 6534 Jamaica 128
Other Name 2973 Bangladesh -1
Bla Bla 5182 India 129
Some Name 7612 London -1
//this is the structure
struct AthleteType
{
string firstName[SIZE];
string lastName[SIZE];
int athleteNumber[SIZE];
string country[SIZE];
int athleteTime[SIZE];
};
void readInput(int SIZE)
{
AthleteType Player[SIZE];
ifstream inputData("Athlete info.txt");
int noOfRecords=0;
for (int i=0; i < SIZE; i++, noOfRecords++)
{
inputData >> Player[i].firstName;
inputData >> Player[i].lastName;
inputData >> Player[i].athleteNumber;
inputData >> Player[i].country;
inputData >> Player[i].athleteTime;
}
for (int i=0; i < noOfRecords; i++)
{
cout << "First Name: " << Player[i].firstName << endl;
cout << "Last Name: " << Player[i].lastName << endl;
cout << "Athlete Number: " << Player[i].athleteNumber << endl;
cout << "Country: " << Player[i].country << endl;
cout << "Athlete Time: " << Player[i].athleteTime << endl;
cout << endl;
}
}
@StoryTeller JFが文字列配列に入力しようとしています。 –
この 'inputData >> Player [i] .firstName;'は 'inputData >> Player.firstName [i];'ではありませんか?それ以外にも構造はかなり無意味に見えます。コードの残りの部分も同様です。 –
@πάνταῥεῖいいね - これは昨日の 'char []'でした! @ Jannatulは非常に急速に進歩している。 –