SHARE
TWEET

Untitled

a guest Nov 20th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. using namespace std;
  5. void Flux_cin()
  6. {
  7. string Ligne;
  8. while (true)
  9. {
  10. getline (cin, Ligne);
  11. if (cin.eof()) break;
  12. cout << Ligne << endl;
  13.  
  14. }
  15. }
  16.  
  17. void AffichFich()
  18. {
  19. ifstream ifs ("LaFontaine.txt");
  20. string Ligne;
  21. while (true)
  22. {
  23. getline (ifs, Ligne);
  24. if (ifs.eof()) break;
  25. cout << Ligne << endl;
  26. }
  27. }
  28.  
  29. void NomFichAuClavier()
  30. {
  31. ifstream ifs;
  32. ofstream ofs;
  33.  
  34. string FichierSource, FichierDestination;
  35. getline (cin, FichierSource);
  36. ifs.open(FichierSource);
  37. getline (cin, FichierDestination);
  38. ofs.open(FichierDestination);
  39. string Ligne;
  40. unsigned Cpt (1);
  41. while (true)
  42. {
  43. getline (ifs, Ligne);
  44. if (ifs.eof()) break;
  45. ofs << Cpt++ << " " << Ligne << endl;
  46. }
  47. }
  48.  
  49. void ValidFichier()
  50. {
  51. ifstream ifs;
  52. ofstream ofs;
  53.  
  54. string FichierSource, FichierDestination;
  55.  
  56. unsigned NbVies (0);
  57. while (true)
  58. {
  59. getline (cin, FichierSource);
  60. ifs.open(FichierSource);
  61. if (ifs.is_open()) break;
  62. ++NbVies;
  63. cout << "Gros boulet" << endl;
  64. if (3 == NbVies)
  65. {
  66. cout << "3 echecs d'ouverture de fichier en lecture" << endl;
  67. return;
  68. }
  69. }
  70.  
  71. NbVies = 0;
  72. while (true)
  73. {
  74. getline (cin, FichierDestination);
  75. ofs.open(FichierDestination);
  76. if (ofs.is_open()) break;
  77. ++NbVies;
  78. cout << "Gros boulet" << endl;
  79. if (3 == NbVies)
  80. {
  81. cout << "3 echecs d'ouverture de fichier en ecriture" << endl;
  82. return;
  83. }
  84. }
  85.  
  86. string Ligne;
  87. unsigned Cpt (1);
  88. while (true)
  89. {
  90. getline (ifs, Ligne);
  91. if (ifs.eof()) break;
  92. ofs << Cpt++ << " " << Ligne << endl;
  93. }
  94. }
  95.  
  96. void FonctionGet()
  97. {
  98. ifstream ifs;
  99.  
  100. string FichierSource;
  101. getline (cin, FichierSource);
  102. ifs.open(FichierSource);
  103. char car;
  104.  
  105. while (true)
  106. {
  107. car = char (ifs.get());
  108. if (ifs.eof()) break;
  109. cout << car /*<< endl*/;
  110. }
  111. }
  112.  
  113. void  ExtractionsMots()
  114. {
  115. string mot;
  116. while (cin >> mot)
  117. cout << mot << endl;
  118. }
  119.  
  120. void ExtractionsCars()
  121. {
  122. char Car;
  123. while (cin >> Car)
  124. cout << Car /*<< endl*/;
  125. }
  126.  
  127. void ExtractionsEntiers()
  128. {
  129. int Entier;
  130. while (cin >> Entier)
  131. cout << Entier << endl;
  132. }
  133.  
  134. void ExtractionsReels()
  135. {
  136. float Reel;
  137. while (cin >> Reel)
  138. cout << Reel << endl;
  139. }
  140.  
  141. int main()
  142. {
  143. //cout << "Hello World!" << endl;
  144. //Flux_cin();
  145. //AffichFich();
  146. //NomFichAuClavier();
  147. ValidFichier();
  148. //FonctionGet ();
  149. //ExtractionsMots ();
  150. //ExtractionsCars();
  151. //ExtractionsEntiers ();
  152. //ExtractionsReels ();
  153. return 0;
  154. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top