Clearing cin input: is cin.ignore not a good way?
<p>What's a better way to clear <code>cin</code> input? I thought <code>cin.clear</code> and <code>cin.ignore</code> was a good way?</p>

<p>Code:</p>

<pre><code> void clearInput()
{   
    cin.clear();
    cin.ignore(1000,'\n');
    //cin.ignore( std::numeric_limits&lt;streamsize&gt;::max(), '\n' );

}
</code></pre>

<p>My teacher gave me this reply:</p>

<blockquote>
  <p>this is basically saying that your
  clearInput doesn't work FYI:  ignore
  is NEVER a good idea as a way of
  getting rid of all that remains on a
  line</p>
  
  <p>and your failing this test is exactly
  the reason why now go clear it the
  correct way</p>
</blockquote>

<p>She has also told me this following:</p>

<blockquote>
  <p>on ignore you need to guess at how
  many characters you want to ignore If
  you absolutely know your data and it
  follows a strict format -- as in Excel
  spreadsheets, ignore is really good. 
  If you are NOT in this type of file,
  then you NEVER use ignore.  Question,
  is your data well-formed?  If yes, use
  ignore.  If not, don't use ignore.</p>
  
  <p>List ALL the way of getting data? 1)
  there is extraction >></p>
  
  <p>and there is also??????</p>
  
  <p>please list for me</p>
</blockquote>
