I am confused about End of File
<p>I am really confused about End of File. Suppose I am running an infinite loop. And in this loop I am taking an integer as input and then processing it, until I find an End of File. But do I check whether the input is an End of File or not. And how do I break the loop. This might seem very basic to you but any help would be appreciated. BTW, I use windows so, for EOF i am typing CTRL+Z.</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;cstdio&gt;
using namespace std;

int main(void)
{
  int n;
  while(true)
  {
    cin &gt;&gt; n;
    if(n==EOF)break;
    cout &lt;&lt; n &lt;&lt; endl;
  }
  return 0;
}
</code></pre>

<p>When I run this code and I type CTRL+z, it prints only the last input I have given, endlessly.</p>
