ajouter des informations à un fichier en C++
Bonjour,
j'aimerai savoir comment je peux ajouter des informations à un fichier avec C++.J'ai essayé de créer un fichier en écriture, j'ai écrit dedans et ça marche bien.Mais, lorsque j'ai ajouté des informations au fichier, le fichier a devenu vide et ne contient aucune information.
voila un bout de mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
ofstream infonetwork;
infonetwork.open("infonetwork.txt",ios::out);
if(infonetwork.is_open())
{
infonetwork <<"NETWORK : " << "\n";
}
else
{
cout<<"anable to open the file \n";
}
infonetwork.close();
infonetwork.open("infonetwork.txt",ios::out);
if(infonetwork.is_open())// Ajout des informations au fichier
{
long pos;
pos=infonetwork.tellp();
infonetwork.seekp(pos+1);
infonetwork.write( " ADJACENCY MATRIX:" ,15);
}
infonetwork.close(); |
Merci d'avance