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?
double num;
cout<< "Enter the number:";
cin>>num;
//How to check?
if( num is illegal )
{
cout << "Error";
return;
}
else
{
//code
}