Using C++, gcc.9x, Linux. I try to open and read file and then keep it opened for further operation - rewrite it for each iteration.
But each time, after I do open
this file - it gets wiped out.
Is it possible to keep file content until I rewrite it ?
And I want to keep file opened for writing all the time.
constructor()
{
{
ifstream tmp("file.db");
int date;
tmp >> date;
}
// it gets wiped out here, but I don't want it.
// And I want to keep ofstream opened all the time.
fileStreamMember_.open("file.db"); // std::ofstream
}
writeMethod()
{
fileStreamMember_.seekp(0, ios::beg);
fileStreamMember_<< date_ << endl;
}