How to check input value given by user doesn't contain any characters?
<p>I want to store a value in double (ex. 1234567890) but when user enter any letter ( ex. 12345a6789) my program goes hang. How can I check whether input value is legal or not?</p>

<pre><code>double num;
cout&lt;&lt; "Enter the number:";
cin&gt;&gt;num;

//How to check?
if( num is illegal )
{
cout &lt;&lt; "Error";
return;
}
else
{
//code
}
</code></pre>