How do you stop reading integer from text file when encounter negative integer?
<p>Im trying to write a simple code in c++ to read in integer from a text file, the code should stop reading when it encounter a negative integer. The txt file contains 1 positive integer on each line, and the last line is a negative integer. </p>

<p>My code right now using eof, and it reads in negative integer also, which I dont want.</p>

<pre><code>while(!inFile.eof())
{
    inFile &gt;&gt; data;
}
</code></pre>

<p>Text file</p>

<pre><code>10
22
33
34
-1   
</code></pre>

<p>Thanks in advance :)</p>
