1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include <fstream>
#include <iostream>
int main()
{
// le constructeur de ifstream permet d'ouvrir un fichier en lecture
std::ifstream fichier( "fichier.txt" );
std::ofstream dest( "destination.txt");
if ( fichier && dest) // ce test échoue si le fichier n'est pas ouvert
{
std::string bidon;
// On saute la première ligne
std::getline(fichier, bidon);
// copier l'intégralité du fichier dans la destination
dest << fichier.rdbuf();
}
std::remove("fichier.txt" );
std::rename("destination.txt", "fichier.txt");
} |
Partager