cin.ignore(3) after failure to get a double with cin >> var
<p>I'm learning c++ with c++ Primer Plus, and I'm on chapter 7 and trying to create the following function:</p>

<pre><code>double getDouble(const char * message){
    double temp;
    std::cout &lt;&lt; (message);
    if (!(std::cin &gt;&gt; temp)){
        std::cin.clear();
        std::cin.ignore(3); // Why does this work specifically?
        std::cout &lt;&lt; "Input not double!" &lt;&lt; std::endl;
        return 0.0;
    }
    return temp;
</code></pre>

<p>}</p>
