Possible Duplicates:
How to validate numeric input C++
how do I validate user input as a double in C++?
I need to get input from the command line and check if it is a valid number... storing it as a double. If the input is invalid, I need to keep asking for a number.
double x;
cout << '>';
cin >> x;
while (/*x is invalid*/){
cout << "Invalid Input! Please input a number." << endl;
cout << '>';
cin >> x;
}
So how do I check if it is valid?