How can I restrict the user to input real numbers only in C++ program?
Example:
double number; cin >> number;
and it won\'t accept t
You cannot restrict what user types on the keyboard. You can accept it as std::string and use boost::lexical_cast to convert it to your expected number type and catch and process boost::bad_lexical_cast exception.
std::string
boost::lexical_cast
boost::bad_lexical_cast