Or from the other way around find first non digit character.
Do the same functions apply for string and for char* ?
Of course, there are many ways to test a string for only numeric characters. Two possible methods are:
bool is_digits(const std::string &str)
{
return str.find_first_not_of("0123456789") == std::string::npos;
}
or
bool is_digits(const std::string &str)
{
return std::all_of(str.begin(), str.end(), ::isdigit); // C++11
}