title: How to read data from files in Turbo c++ 4.0?
body: <p>I am a beginner in programming and I am trying to make a code that reads 2 numbers from a file and then 
  displays it in the output window on turbo c++. My code only reads the first number and produces incorrect output
   for the second number.</p>
  
  <pre><code> #include&lt;iostream.h&gt;
   #include&lt;fstream.h&gt;
   #include&lt;conio.h&gt;
  
  void main()
  {
    int x, y;
    clrscr();
    ifstream inFile;
    ofstream outFile;
    inFile.open("prac.txt");
  
    while(!inFile.eof())
    inFile &gt;&gt; x &gt;&gt; y;
    cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y;
  
    inFile.close();
  
   }
  </code></pre>
  
  <p>The file contains the numbers: <code>2</code> <code>3</code> </p>
  
  <p>Output : <code>2</code> <code>0</code> </p>
  
  <p>Output when called as a function: <code>2</code> <code>-28903</code> which is very different if I call it as a function compared when its in main  which is what I was supposed to be doing
   I was just using it in main to see what happens.</p>
  
  <p>Sorry, but our teacher wanted us to learn in Turbo c++ so I don't 
  really have choice with the compiler.</p>