Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. ///Idee du programme : aller jusqu'à un espace, prendre ce qu'il y a dans l'int où ça recommence et où on arrive à l'espace, si c'est une fois immpaire qu'on s'arrête, alors c'est un nom
  6. ///si c'est une fois paire, alors c'est un prenom. Traiter chaque couple nom-prenom à la fois
  7.  
  8.  
  9.  
  10. using namespace std;
  11.  
  12. ///Fonction (P. Nom)///
  13. string formattage(string nom, string prenom)
  14. {
  15.     nom=nom[0]+".";
  16.     nom+=prenom;
  17.     return nom;
  18. }
  19. int main()
  20. {
  21.     ifstream fichier("users.txt");
  22.     if(fichier.is_open())
  23.     {
  24.         string nom,prenom;
  25.         while(fichier >> nom && fichier >> prenom)
  26.         {
  27.             cout << formattage(nom, prenom) << endl;
  28.         }
  29.     }
  30.     else
  31.         cout << "ERREUR Le fichier ne s'est pas ouvert" << endl;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement