title: Problem of using cin twice
body: <p>Here is the code:</p>
  
  <pre><code>string str;
  cin>>str;
  cout&lt;&lt;"first input:"&lt;&lt;str&lt;&lt;endl;
  getline(cin, str);
  cout&lt;&lt;"line input:"&lt;&lt;str&lt;&lt;endl;</code></pre>
  
  <p>The result is that getline never pauses for user input, therefore the second output is always empty.</p>
  
  <p>After spending some time on it, I realized after the first call "cin>>str", it seems '\n' is still stored in cin (using cin.peek() to check), which ends getline immediately. The solution will be adding one more line between the first usage and the second one:
  <code>cin.ignore(numeric_limits::max(), '\n');</code></p>
  
  <p>However, I still don't understand, why is '\n' left there after the first call? What does istream&amp; operator>> really do?</p>