Answers for "how if a string has numbers only in c++"

C++
0

c++ function for checking if a sting is a number

bool is_number(const std::string& s)
{
    std::string::const_iterator it = s.begin();
    while (it != s.end() && std::isdigit(*it)) ++it;
    return !s.empty() && it == s.end();
}
Posted by: Guest on October-21-2021

Code answers related to "how if a string has numbers only in c++"

Browse Popular Code Answers by Language