C++ Help

i forgot to mention, in order to use the file streams in c++, u must include the fstream.h header…

oh, and to write in a file u use the ‘ofstream’ object class, like this:

ofstream file(“highscores”,ios::app);
//i’ve used ios::app, cause i want to write information at the end of the file
file<<’
'<<variable;
file.close();

remember not to use ifstream file() and then declare ofstream file() --i mean, don’t use the same name files for reading and writing, cause it will give you a compilation error

anyway, u can also use the file.open() command after you’ve declared it’s type, which may be ‘fstream’… what i mean is you can do this:

fstream file;
file.open(“highscores”,ios::in); //open for reading
//procces file
file.close();
file.open(“highscores”,ios::out | ios::app); //open at the end of file for writing
file.close();

//don’t forget to use the .close() fstream class member function