isxdigit Function

Test for a hexadecimal digit.

Include

<ctype.h>

Prototype

int isxdigit (int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character, c, is a hexadecimal digit; otherwise, returns zero.

Remarks

A character is considered to be a hexadecimal digit character if it is in the range of ‘0’-‘9’, ‘A’-‘F’, or ‘a’-‘f’.

Note: The list does not include the leading 0x because 0x is the prefix for a hexadecimal number but is not an actual hexadecimal digit.

Example

#include <ctype.h>
#include <stdio.h>

int main(void)
{
  int ch;

  ch = 'B';
  if (isxdigit(ch))
    printf("B is a hexadecimal digit\n");
  else
    printf("B is NOT a hexadecimal digit\n");

  ch = 't';
  if (isxdigit(ch))
    printf("t is a hexadecimal digit\n");
  else
    printf("t is NOT a hexadecimal digit\n");
}

Example Output

B is a hexadecimal digit
t is NOT a hexadecimal digit