Answers for "how to check if a string contains only a number inc++"

6

check if string contains numbers

str.matches(".*\\d.*");
Posted by: Guest on November-01-2020
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 to check if a string contains only a number inc++"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language