ok i got another problem now im trying to save a file and read a file (not at the same time) but it keeps coming up with these errors
Code:
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(87) : error C2676: binary '>>' : 'class std::basic_ofstream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to
the predefined operator
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::al
locator<char> >' (or there is no acceptable conversion)
C:\Windows\Profiles\programming\Desktop\New Folder\text rpg my version0.0001.cpp(125) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
here is the code
Code:
void Save()
{
ofstream fout;
string szLine ="";
string szWord = "";
string Name = Name;
fout.open("Stats.dat");
fout << "Name: " <<Name <<endl;
fout << "Life: " <<Life <<endl;
fout << "Maxlife: " <<Maxlife <<endl;
fout << "Money: " <<Money <<endl;
fout << "Potions: " <<Potions <<endl;
fout << "Spells: " <<Spells <<endl;
fout << "Level: " <<Level <<endl;
fout << "NLevel: " <<NLevel <<endl;
fout << "EPoints: " <<EPoints <<endl;
fout << "EOld: " <<EOld <<endl;
fout << "EGained: " <<EGained <<endl;
fout << "Power: " <<Power <<endl;
fout << "PotionP: " <<PotionP <<endl;
fout << "MagicP: " <<MagicP <<endl;
fout.close();
}
void Open()
{
ifstream fin;
string szLine = "";
string szWord = "";
string szName = "";
fin.open("Stats.txt");
if(fin.fail())
{
cout << "ERROR: Could not find Stats.txt!\n";
return;
}
cout << endl;
while(fin >> szWord)
cout << szWord;
cout << endl;
fin.clear();
fin.seekg(NULL, ios::beg);
while(getline(fin, szLine))
cout << szLine << endl;
cout << endl;
fin.clear();
fin.seekg(NULL, ios::beg);
fin >> szWord >> Name;
fin >> szWord >> Life;
fin >> szWord >> Maxlife;
fin >> szWord >> Money;
fin >> szWord >> Potions;
fin >> szWord >> Spells;
fin >> szWord >> Level;
fin >> szWord >> NLevel
fin >> szWord >> EPoints;
fin >> szWord >> EOld;
fin >> szWord >> EGained;
fin >> szWord >> Power;
fin >> szWord >> PotionP;
fin >> szWord >> MagicP;
fin.close(); .
}
thanx if you can help