title: C++ File I/O - Program suspends
body: <p>I have a homework problem here I've been working on; here is the description:</p>
  
  <blockquote>
    <p>Write a program that reads a file consisting of students’ test scores in the
    range 0–200. It should then determine the number of students having
    scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99,
    100–124, 125–149, 150–174, and 175–200. Output the score ranges
    and the number of students. (Run your program with the following input
    data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200,
    175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)</p>
  </blockquote>
  
  <p>The following is the program I have made:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main() 
  {
  //declaring variables
  ifstream myfile("data.txt");
  double grades[26];
  int i, studentNumber=0;
  int score0_24=0, score25_49=0, score50_74=0,
      score75_99=0, score100_124=0, score125_149=0,
      score150_174=0, score175_200=0;
  
  cout &lt;&lt; score150_174 &lt;&lt; endl;
  
  //initializing grades array
  for(i=0; i&lt;26; i++)
  {
      grades[i] = 0;
      cout &lt;&lt; grades[i] &lt;&lt; " ";
  }
  
  //getting data from text file
      for(i=0; i&lt;26; i++)
          {
              myfile &gt;&gt; grades[i];
              cin.ignore(2);
              studentNumber++;
          }
  
      myfile.close();
  
  //finding number of people for each score range
  for(i=0; i&lt;26; i++)
  {
      if(grades[i] &lt;= 24)
          score0_24++;
      if(grades[i] &gt;= 25 &amp;&amp; grades[i] &lt;= 49)
          score25_49++;
      if(grades[i] &gt;= 50 &amp;&amp; grades[i] &lt;= 74)
          score50_74++;
      if(grades[i] &gt;= 75 &amp;&amp; grades[i] &lt;= 99)
          score75_99++;
      if(grades[i] &gt;= 100 &amp;&amp; grades[i] &lt;= 124)
          score100_124++;
      if(grades[i] &gt;= 125 &amp;&amp; grades[i] &lt;= 149)
          score125_149++;
      if(grades[i] &gt;= 150 &amp;&amp; grades[i] &lt;= 174)
          score150_174++;
      if(grades[i] &gt;= 175 &amp;&amp; grades[i] &lt;= 200)
          score175_200++;
  }
  
  //outputing results
  cout &lt;&lt; "Number of students: " &lt;&lt; studentNumber &lt;&lt; endl;
  cout &lt;&lt; "0-24: " &lt;&lt; score0_24 &lt;&lt; endl;
  cout &lt;&lt; "25-49: " &lt;&lt; score25_49 &lt;&lt; endl;
  cout &lt;&lt; "50-74: " &lt;&lt; score50_74 &lt;&lt; endl;
  cout &lt;&lt; "75-99: " &lt;&lt; score75_99 &lt;&lt; endl;
  cout &lt;&lt; "100-124: " &lt;&lt; score100_124 &lt;&lt; endl;
  cout &lt;&lt; "125-149: " &lt;&lt; score125_149 &lt;&lt; endl;
  cout &lt;&lt; "150-174: " &lt;&lt; score150_174 &lt;&lt; endl;
  cout &lt;&lt; "175-200: " &lt;&lt; score175_200 &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  
  <p>And the file I have, which is in the same folder as this project, is called:</p>
  
  <blockquote>
    <p>data.txt</p>
  </blockquote>
  
  <p>And contains the following:</p>
  
  <blockquote>
    <p>76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189</p>
  </blockquote>
  
  <p>When I run the program, it suspends during the for loop where I read data from the file. I've tried doing some cout statements right before and after, and it seems that is the problem.</p>
  
  <p>Help would be appreciated.</p>