title: Reading from a txt file with a specific format into variables in c++
body: <p>I am having a hard time with an assignment, I am given a .txt file with data in the following format:</p>
  
  <pre><code>Michael Schumacher
  Allemagne; 250 91
  1994 1995 2000 2001 2002 2003 2004
  Benetton; Ferrari;
  Fernando Alonso
  Espagne; 132 21
  etc...
  </code></pre>
  
  <p>I need to read this file and funnel the data in appropriate variables:</p>
  
  <pre><code>full name                                   ----&gt; to string
  country; numberOfRace numberOfVictories     ----&gt; to string; to int, to int
  all years separated by spaces               ----&gt; to an array
  Sponsor1; [Sponsor2(optional)];             ----&gt; to an array
  full name2.....
  </code></pre>
  
  <p>I have spent 3 days trying to assign the data properly with a mixture of getlines and file >> and can't manage to get the array right, here my most recent attempt:</p>
  
  <pre><code>for (int i = 0; i &lt; NPILOTES; i++) {
          getline(fichier, liste.pilotes[i].nom);
          getline(fichier, liste.pilotes[i].pays, ';');
  
          fichier &gt;&gt; liste.pilotes[i].nCourses;
          fichier &gt;&gt; liste.pilotes[i].nVictoires;
          fichier.ignore();
  
          // liste des annees
          string line;
          getline(fichier, line);
  
          int position = 0, compteur = 0;     
          while ((position + 4) &gt; line.length()) {    // doesn't work, nothing gets in the array
              line.substr(position, 4) =
                liste.pilotes[i].annees.liste[compteur];
              position += 5;
              compteur++;
          }
          liste.pilotes[i].annees.n = compteur;
  
          // liste des constructeurs automobiles
          getline(fichier, line);
          //????
      }
  </code></pre>
  
  <p>variable names are in french as required by my class but it shouldn't be too hard to understand(pays = country, annees = years, constructeur = sponsor). Please keep in mind it's a first year programming class, so I am not allowed to use advanced concept like objects and vectors...</p>
  
  <p>Thanks in advance for your input</p>