title: Assigning file data to array of structs
body: <p>I'm currently attempting to assign a line of data from an input file to an array of structs.</p>
  
  <p>Here is my struct:</p>
  
  <pre><code>struct student
      {
          int ID;
          int hours;
          float GPA;
      };
  
      student sStudents[MAX_STUDENTS]; // MAX_STUDENTS = 10
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>for (int i = 0; !inputFile.eof(); i++)
  {
      getline(inputFile, dataLine);
      cout &lt;&lt; dataLine &lt;&lt; endl; // Everything outputs perfectly, so I know dataLine is getting the correct information from getline()
              //??
  }
  </code></pre>
  
  <p>After an hour of crawling through Google I still don't have an idea of how to get my getline() data into each struct array.</p>
  
  <p>I have tried,</p>
  
  <pre><code>sStudents[i] = dataLine;
  sStudents[i] &lt;&lt; dataLine;
  sStudents.ID = dataLine;
  </code></pre>
  
  <p>Here is my data file:</p>
  
  <pre><code>1234  31  2.95
  9999  45  3.82
  2327  60  3.60
  2951  68  3.1
  5555  98  3.25
  1111  120 2.23
  2222  29  4.0
  </code></pre>
  
  <p>At this point I've become frustrated and I'm just not sure what to do. I'm convinced at this point I'm going about it completely incorrectly but not sure how to continue from here. I know that 10 elements of sStudents exist so that's good but how can I get the values from the input file into each .ID, .hours, .GPA? Perhaps getline() is being used incorrectly here?</p>