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 26 27 28 29 30 31
| int main()
{
string const fichierEntree("fichier.txt");
string const fichierSortie ("sortie.txt");
vector<string> data;
ifstream fluxEntree(fichierEntree.c_str(), ios::in);
ofstream fluxSortie(fichierSortie.c_str(), ios::app);
if(fluxEntree)
{
string ligne;
while(getline(fluxEntree, ligne))
{
regex pattern { ", ," };
string target { ligne };
string replacement { "," };
ligne = regex_replace(target, pattern, replacement);
}
data.push_back(ligne);
}
fluxEntree.close();
}
else
{
cout << "Erreur : Impossible d'ouvrir le fichier !" << endl;
}
for(auto &ligne : data)
fluxSortie << ligne << endl ;
return 0;
} |