Comment on fait pour écrire en c++ dans un fichier teste sur
http://c.developpez.com/faq/cpp/?page=fichiers#FICHIERS_ofstream_appendJ'ai trouvé ca :
#include <fstream>
void AjouterUneLigne()
{
// std::ios_base::out est automatiquement ajouté par le
// constructeur de std::ofstream
std::ofstream file( "fichier.txt", std::ios_base::app );
file << "Une ligne\n";
}
int main()
{
// création du fichier et écriture d'une ligne
AjouterUneLigne();
// ouverture du fichier existant et rajout d'une nouvelle ligne
AjouterUneLigne();
// "fichier.txt" contient 2 lignes
}
C'est ca ou pas ?