isdigit

Header: <ctype.h>

Checks if the given character is a numeric character (0123456789).

# Declarations

int isdigit( int ch );

# Parameters

# 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.

# Example

#include <ctype.h>
#include <limits.h>
#include <stdio.h>
 
int main(void)
{
    for (int ndx = 0; ndx <= UCHAR_MAX; ++ndx)
        if (isdigit(ndx))
            printf("%c", ndx);
    printf("\n");
}

# See also