All pastes #386753 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-08 21:27 UTC
rendered paste body
AVANT/////////////////////////////////////////////////////

void lireRemplir(char nomALire[], int chandail[], double taille[], 
                 double poids[], int naissance[], int position[], 
                 string nomPre[], int & n)
{ 
  ifstream  aLire (nomALire, ios::in); // localiser et ouvrir pour la lecture
  n = 0; // initialiser le compteur
  string ligne;
  while(  getline(aLire, ligne, '\n'))
    {				
      chandail[n] = atoi((ligne.substr(0,3)).c_str()); 
      int pieds = atoi((ligne.substr(4,1)).c_str());
      int pouces = atoi((ligne.substr(6,2)).c_str());
      taille[n] = (pieds + pouces / 12.0) * PIED_EN_METRE; 
      // On demande la taille en système métrique
      int lbs = atoi((ligne.substr(13,3)).c_str());
      poids[n] = lbs * LBS_EN_KG;
      // On demande le poids en système métrique 
      naissance[n]  = atoi((ligne.substr(19,4)).c_str());
      position[n]  = atoi((ligne.substr(26,1)).c_str());
      nomPre[n] = ligne.substr(30); 
      // de l'indice 30 jusqu'Ã  la fin
      n++;
    }
  aLire.close();   
}


APRES ///////////////////////////////////


void lireRemplir(char nomALire[], Joueur tab[], int & n)
{ 
  ifstream  aLire (nomALire, ios::in); // localiser et ouvrir pour la lecture
  n = 0; // initialiser le compteur
  string ligne;
  while(  getline(aLire, ligne, '\n'))
    {				
      tab[n].chandail = atoi((ligne.substr(0,3)).c_str()); 
      int pieds = atoi((ligne.substr(4,1)).c_str());
      int pouces = atoi((ligne.substr(6,2)).c_str());
      tab[n].taille = (pieds + pouces / 12.0) * PIED_EN_METRE; 
      // On demande la taille en système métrique
      int lbs = atoi((ligne.substr(13,3)).c_str());
      tab[n].poids = lbs * LBS_EN_KG;
      // On demande le poids en système métrique 
      tab[n].naissance = atoi((ligne.substr(19,4)).c_str());
      tab[n].position = atoi((ligne.substr(26,1)).c_str());
      tab[n].nomPre = ligne.substr(30); 
      // de l'indice 30 jusqu'Ã  la fin
      n++;
    }
  aLire.close();   
}