title: Cannot Print All Integer Values
body: <p>I would like to print integer values in a file by reading it. </p>
  
  <p>The code:  </p>
  
  <pre><code>    int temp;
      char* trainname;
      trainname="dfg.txt";
      ifstream trainfile;
      trainfile.open(trainname);
      if(!trainfile){
          cout&lt;&lt;"Cannot open file!"&lt;&lt;'\n';
          exit(1);
      }
      while(trainfile &gt;&gt; temp)
          cout &lt;&lt; temp &lt;&lt; " ";
      trainfile.close();
  </code></pre>
  
  <p>dfg.txt: <code>1  2  we er rf 5</code></p>
  
  <p>output: <code>1 2</code></p>
  
  <p>The problem is that it does not print <code>5</code>.</p>