how to clear the unneccessary input stream in C++
<p>I would like to make the user input a center number of character, e.g. 10, however, the user might input more than 10. </p>

<pre><code>for(int i = 0 ; i&lt; 10 ; i++)
cin&gt;&gt;x;
</code></pre>

<p>The extra character could make my code crash since I will ask for input later. </p>

<p>How can I clear the input at this moment when the user input more than 10?</p>

<p>Thanks so much!</p>
