(C++) std::isdigit
January 26, 2018 · View on GitHub
(C++) std::isdigit
std::isdigit is an STL function to test of a character is a decimal digit.
#include <cassert> #include <string> int main() { const std::string s = "1a"; //'a' is no decimal digit assert( std::isdigit(s[0])); assert(!std::isdigit(s[1])); //'a' is a hexadecimal digit assert( std::isxdigit(s[0])); assert( std::isxdigit(s[1])); }