title: C++: how do I remove bad input from cin?
body: <p>I have done some <code>cin</code> operation and before I use <code>cin</code> I want to clear its state and 
  flush it. How do I do it? I know <code>cin.clear()</code> clears the error state but to flush the <code>cin</code>
  buffer how do I check if it's empty and if not which of the below statements shall I use to empty it so that I can safely use <code>cin</code> later?</p>
  
  <pre><code>cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max()); 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n'); 
  </code></pre>