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 7 - Fonctions seekg() et tellg() Lun 17 Déc - 14:04 | |
| - Code:
-
/** * * @file SeekgTellg.cxx * * @authors M. Laporte, D. Mathieu * * @date 18/11/2011 * * @version V1.0 * * @brief Calcul de la taille d'un fichier * **/
#include <iostream> #include <string> #include <fstream>
using namespace std;
namespace { void SeekgTellg (void) { cout << "Taille d'un fichier\n\n"; ifstream is; for ( ; ! is.is_open(); ) { string FicSource; cout << "Nom du fichier source : "; getline (cin, FicSource);
is.open (FicSource.c_str ());
if (!is.fail ()) break; cout << "Le fichier " << FicSource << " ne peut etre ouvert en lecture\n"; is.clear(); } is.seekg (0, std::ios_base::end); cout << "Taille du fichier " << is.tellg() << '\n'; } // SeekgTellg() } // namespace
int main (void) { /* * / Flux_cin (); /* */ /* * / AffichFich (); /* */ /* * / NomFichAuKbd (); /* */ /* * / ValidFichier (); /* */
/* * / ExtractionMots (); /* */ /* * / ExtractionCars (); /* */ /* * / ExtractionEntiers(); /* */ /* * / ExtractionReels (); /* */
/* * / FonctionGet (); /* */
/* */ SeekgTellg (); /* */
return 0;
} // main()
| |
|