Sorell Stratège
Nombre de messages : 521 Localisation : Quel part où le sang coule. Date d'inscription : 01/05/2008
Feuille de personnage Surnom dans la team: Sénéchal Noir Victoire/défaite: (0/0)
| Sujet: TP3 Exercice 5 - Extractions diverses par l'opérateur >> Lun 17 Déc - 13:51 | |
| - Code:
-
/** * * @file Extractions.cxx * * @authors M. Laporte, D. Mathieu * * @date 18/11/2011 * * @version V1.0 * * @brief extractions diverses d'un flux * **/
#include <iostream> #include <string>
using namespace std;
namespace { void ExtractionMots (void) { cout << "Extraction d'une suite de mots au clavier\n\n"; string MotLu;
for (cin >> MotLu; !cin.eof(); cin >> MotLu) cout << "Mot lu : " << MotLu << '\n'; } // ExtractionMots() void ExtractionCars (void) { cout << "Extraction d'une suite de caracteres au clavier\n\n"; char CarLu;
for (cin >> CarLu; !cin.eof(); cin >> CarLu) cout << "Caractere lu : " << CarLu << '\n'; } // ExtractionCars() void ExtractionEntiers (void) { cout << "Lecture d'une suite d'entiers au clavier\n\n"; unsigned short EntierLu; for (cin >> EntierLu; !cin.fail(); cin >> EntierLu) cout << "Entier lu : " << EntierLu << '\n'; } // ExtractionEntiers() void ExtractionReels (void) { cout << "Lecture d'une suite de reels au clavier\n\n"; double ReelLu; for (cin >> ReelLu; !cin.fail(); cin >> ReelLu) cout << "Réel lu : " << ReelLu << '\n'; } // ExtractionReels() } // namespace
int main (void) { /* * / Flux_cin (); /* */ /* * / AffichFich (); /* */ /* * / NomFichAuKbd (); /* */ /* * / ValidFichier (); /* */
/* * / ExtractionMots (); /* */ /* * / ExtractionCars (); /* */ /* * / ExtractionEntiers(); /* */ /* */ ExtractionReels (); /* */
return 0;
} // main()
| |
|