std::isdigit
Header: <cctype>
Checks if the given character is one of the 10 decimal digits: (0123456789).
# Declarations
int isdigit( int ch );
# Parameters
ch: character to classify
# Return value
Non-zero value if the character is a numeric character, zero otherwise.
# Notes
isdigit and isxdigit are the only standard narrow character classification functions that are not affected by the currently installed C locale. although some implementations (e.g. Microsoft in 1252 codepage) may classify additional single-byte characters as digits.
Like all other functions from
Similarly, they should not be directly used with standard algorithms when the iterator’s value type is char or signed char. Instead, convert the value to unsigned char first:
# Example
#include <cctype>
#include <climits>
#include <iostream>
int main(void)
{
for (int i = 0; i <= UCHAR_MAX; ++i)
if (std::isdigit(i))
std::cout << static_cast<unsigned char>(i);
std::cout << '\n';
}