pb : Ecrire à la fin d'un fichier
Salut !!
Comment je peux faire pour rajoutter des données à la fin d'un fichier à chaque fois que je fais appel de ma méthode d'écriture?
J'ai fait le suivant, mais cela ne fait que surécrire mais pas rajoutter des données ...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
void GlobalStat::makeStat(Player * iPlayer, int iYear, const std::string & iNameFile)
{
//std::cout << "This is the creation of a file" << std::endl;
ofstream aOutdata; // outdata is like cin
if (!aOutdata.is_open())
aOutdata.open(iNameFile.c_str()); // opens the file
// if file couldn't be opened => TODO create a file exception in the future
if( !aOutdata )
{
cerr << "Error: file could not be opened" << std::endl;
exit(1);
}
aOutdata << "This is the creation of a file" << std::endl;
aOutdata.close();
} |
Merci !!