Validating input in C++
<p>I have this code:</p>

<pre><code>double input2;
cout&lt;&lt;"please enter one number:"&lt;&lt;endl;
cin&gt;&gt;input2;
</code></pre>

<p>How can I judge if the user input only about digits, like '3', '4', or '4.241'. Sometimes when users enter a character like 'n', '3.q', my program will crash.</p>
