title: why does while loop using cin.get() function outputs result twice?
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  int main()
  {
  
      int a ;
      while ( ( a = cin.get() ) != EOF )
      {
  
         cout &lt;&lt; "hi" &lt;&lt;endl;
  
       } // end while
  
  
  }
  </code></pre>
  
  <p>I wonder why this outputs "hi" twice whenever I input once.</p>
  
  <p>for example</p>
  
  <p>input : 1
  output : hi 
           hi</p>