-1

この質問に答えようとしている間は、より具体的になるようにしてください。追加の詳細はありません。エラーが発生します

no match for operator<< in theFileIn<<number
#include<iostream>
#include<fstream>

using namespace std;

int main()
{
int number;
string name;

ofstream theFileOut;
ifstream theFileIn;

theFileOut.open("Sansa.txt");
cout << "Enter the number and the name"<<endl;

while(cin>> number>> name)
{
    theFileOut<<number<<" "<<name<<endl;
}

theFileOut.close();
theFileIn.open("sansa.txt");

while(theFileIn>>number>>name)
{
    theFileIn << number<<" "<<name<<endl;
}

return 0;
}
4

2 に答える 2

2

問題はここにあります:

  theFileIn << number<<" "<<name<<endl;

theFileInはオブジェクトです。ifstream オブジェクトでifstreamは使用できません。<<あなたはおそらく次のことを意味します:

 cout << number<<" "<<name<<endl;
于 2013-06-25T15:49:05.603 に答える
1

ここに問題があります:

theFileIn<<number<<" "<<name<<endl;

他のものに切り替える必要があります。theFileOut最善の方法はcoutです。

于 2013-06-25T15:50:39.803 に答える