title: Read data file into an array
body: <p>I am trying to read a text file and store it in an array, but my program keeps getting stuck in an infinite loop.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>int main () {
      const int size = 10000; //s = array size
      int ID[size];
      int count = 0; //loop counter
      ifstream employees;
  
      employees.open("Employees.txt");
      while(count &lt; size &amp;&amp; employees &gt;&gt; ID[count]) {
          count++;
      }
  
      employees.close(); //close the file 
  
      for(count = 0; count &lt; size; count++) { // to display the array 
          cout &lt;&lt; ID[count] &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  }
  </code></pre>