Namespaces
Variants
Actions

isxdigit

From cppreference.com
< c‎ | string‎ | byte
Defined in header <ctype.h>
int isxdigit( int ch );

Checks if the given character is a hexadecimal numeric character (0123456789abcdefABCDEF) or is classified as a hexadecimal character.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Contents

[edit] Parameters

ch - character to classify

[edit] Return value

Non-zero value if the character is an hexadecimal numeric character, zero otherwise.

[edit] 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.

[edit] Example

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

Output:

0123456789ABCDEFabcdef

[edit] References

  • C23 standard (ISO/IEC 9899:2024):
  • 7.4.1.12 The isxdigit function (p: TBD)
  • C17 standard (ISO/IEC 9899:2018):
  • 7.4.1.12 The isxdigit function (p: 147)
  • C11 standard (ISO/IEC 9899:2011):
  • 7.4.1.12 The isxdigit function (p: 203)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.4.1.12 The isxdigit function (p: 184)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 4.3.1.11 The isxdigit function

[