I have some problems with my engine, as I try to save/restore configuration from a class to the hard drive.
I overloaded the fstream operators this way:
fstream& operator>>( fstream& istr, CConfig& C );
fstream& operator<<( fstream& ostr, CConfig& C );
my file stream is initialized this way:
cfgfile = new fstream( DEFAULT_CFG_FILE, ios::in | ios: ut | ios::binary );
initialized this way:
if (cfgfile && (cfgfile->eof() == 0))
*cfgfile >> *cfg;
else
cfg->Default();
and saved this way:
*cfgfile << *cfg;
cfgfile->close();
problem : no data is wrote on the hard drive, the operator code is the following:
fstream& operator<<( fstream& ostr, CConfig& C )
{
ostr.seekp( 0, ios::beg );
int pos = ostr.tellp();
ostr << C.ID;
… other data writing code here …
ostr << flush;
pos = ostr.tellp();
return ostr;
}
the first tellp returns 0, the second tellp returns 0… I don’t understand… can anyone help me ?
thank you in advance,