All pastes #386734 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-08 21:17 UTC
rendered paste body
#include "stdafx.h" // environnement VC++ version 2005 
#include <iostream>  // pour entrée-sortie  cin, cout 
#include <iomanip>   // pour le formatage 
#include <string>    // chaîne de caractères 
#include <fstream>   // pour les fichiers 

using namespace std; // librairie standard 
struct Canadiens { 

    int numero, naissance, position; 
               double taille, poids; 
    string nom; 

}; 


void lireRemplir(char *nomFichier, Canadiens joueur[], int & n) 
{ 

    ifstream  aLire(nomFichier, ios::in); 
    n = 0; 

   string ligne; 

   while(  getline(aLire, ligne, '\n')){ 

   
       joueur[n].nom  = ligne.substr(30); 
       joueur[n].numero = atoi((ligne.substr(1,2)).c_str()); 
       joueur[n].taille = atoi((ligne.substr(4,7)).c_str()); 
       joueur[n].poids = atoi(ligne.substr(14,16).c_str()); 
       joueur[n].position = atoi((ligne.substr(27,28)).c_str()); 
       
   cout << ligne << endl; 
        n++; 

    } 

    aLire.close(); 
    cout << "On vient de lire " << n << " pays\n"; 
	
} 



void main() 
{ 
    const  int MAX_PERS = 25; 
    int nbjoueur; 
    Canadiens* joueur = new Canadiens[MAX_PERS]; 
lireRemplir("R:\\canadiens.txt",joueur, nbjoueur); 


}