title: Clear the cin buffer before another input request, c++
body: <p>I have the following code:    </p>
  
  <pre><code>int choice = 0;
  char st1[N];
  
  cout &lt;&lt; "enter choice" &lt;&lt;endl;
  cin &gt;&gt; choice;
  
  cout &lt;&lt; "enter sentence" &lt;&lt; endl;
  cin.get(st1, N-1);
  </code></pre>
  
  <p>when getting to cin.get line, no matter what the input is, it will read \0 char into st1[0]
  and that's it.</p>
  
  <p>I assume it has something to do with the latest cin ( into choice variable ).</p>
  
  <p>How do i "clean" cin buffer before getting new input from the user? if that's possible.</p>
  
  <p>thanks</p>