title: Infinite Loop due to cout<<cin.rdbuf(), why?
body: <p>i write a program for read input from console and write agian on console. So i used following code.</p>
  
  <pre><code>#include&lt;iostream&gt;
  int main()
  {
      using namespace std;
      cout&lt;&lt;cin.rdbuf();
      cin.get();
      return 0;
  }
  </code></pre>
  
  <p>but it goes in infinite loop. always getting input and printing it back. can anyone explain , what is happening here ?</p>
  
  <p>it generate following output:</p>
  
  <p>(wait for input : enter g)</p>
  
  <pre><code>g
  g
  </code></pre>
  
  <p>(again wait for input : enter h (any char))</p>
  
  <pre><code>h
  h
  </code></pre>
  
  <p>(still wait for input : enter h (any char))</p>
  
  <pre><code>h
  h
  </code></pre>
  
  <p>so on, program always wait for input when i enter any charecter it just print it. again wait for input. it do not terminate</p>