Clearing a carriage return from memory in C++
<p>I have the following code:</p>

<pre><code>int main()
{
// Variables
char name;

// Take the users name as input
cout &lt;&lt; "Please enter you name..." &lt;&lt; endl;
cin &gt;&gt; name;


// Write "Hello, world!" and await user response
cout &lt;&lt; "Hello, " &lt;&lt; name &lt;&lt; "!" &lt;&lt; endl;
cout &lt;&lt; "Please press [ENTER] to continue...";
cin.get();

return 0;
</code></pre>

<p>}</p>

<p>After the user hits return to enter their name, that carriage return is carried forward to the end of the code where it is immediately applied as input to cin.get(), thus ending the program prematurely. What can I place on the line immediately following</p>

<pre><code>cin &gt;&gt; name;
</code></pre>

<p>to stop this from happening? I know that it's possible, as I've done it before, but can't remember what it is or where I can find it. Thanks a lot in advance.</p>
