Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- void Flux_cin()
- {
- string Ligne;
- while (true)
- {
- getline (cin, Ligne);
- if (cin.eof()) break;
- cout << Ligne << endl;
- }
- }
- void AffichFich()
- {
- ifstream ifs ("LaFontaine.txt");
- string Ligne;
- while (true)
- {
- getline (ifs, Ligne);
- if (ifs.eof()) break;
- cout << Ligne << endl;
- }
- }
- void NomFichAuClavier()
- {
- ifstream ifs;
- ofstream ofs;
- string FichierSource, FichierDestination;
- getline (cin, FichierSource);
- ifs.open(FichierSource);
- getline (cin, FichierDestination);
- ofs.open(FichierDestination);
- string Ligne;
- unsigned Cpt (1);
- while (true)
- {
- getline (ifs, Ligne);
- if (ifs.eof()) break;
- ofs << Cpt++ << " " << Ligne << endl;
- }
- }
- void ValidFichier()
- {
- ifstream ifs;
- ofstream ofs;
- string FichierSource, FichierDestination;
- unsigned NbVies (0);
- while (true)
- {
- getline (cin, FichierSource);
- ifs.open(FichierSource);
- if (ifs.is_open()) break;
- ++NbVies;
- cout << "Gros boulet" << endl;
- if (3 == NbVies)
- {
- cout << "3 echecs d'ouverture de fichier en lecture" << endl;
- return;
- }
- }
- NbVies = 0;
- while (true)
- {
- getline (cin, FichierDestination);
- ofs.open(FichierDestination);
- if (ofs.is_open()) break;
- ++NbVies;
- cout << "Gros boulet" << endl;
- if (3 == NbVies)
- {
- cout << "3 echecs d'ouverture de fichier en ecriture" << endl;
- return;
- }
- }
- string Ligne;
- unsigned Cpt (1);
- while (true)
- {
- getline (ifs, Ligne);
- if (ifs.eof()) break;
- ofs << Cpt++ << " " << Ligne << endl;
- }
- }
- void FonctionGet()
- {
- ifstream ifs;
- string FichierSource;
- getline (cin, FichierSource);
- ifs.open(FichierSource);
- char car;
- while (true)
- {
- car = char (ifs.get());
- if (ifs.eof()) break;
- cout << car /*<< endl*/;
- }
- }
- void ExtractionsMots()
- {
- string mot;
- while (cin >> mot)
- cout << mot << endl;
- }
- void ExtractionsCars()
- {
- char Car;
- while (cin >> Car)
- cout << Car /*<< endl*/;
- }
- void ExtractionsEntiers()
- {
- int Entier;
- while (cin >> Entier)
- cout << Entier << endl;
- }
- void ExtractionsReels()
- {
- float Reel;
- while (cin >> Reel)
- cout << Reel << endl;
- }
- int main()
- {
- //cout << "Hello World!" << endl;
- //Flux_cin();
- //AffichFich();
- //NomFichAuClavier();
- ValidFichier();
- //FonctionGet ();
- //ExtractionsMots ();
- //ExtractionsCars();
- //ExtractionsEntiers ();
- //ExtractionsReels ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement