Facebook Page Twitter Page LinkedIn Page
× C Standard Library

The C <ctype.h> isxdigit() function is used to check if the given character is a hexadecimal digit or not. Hexadecimal digits are one of the following character: 0123456789abcdefABCDEF.


int isxdigit ( int ch );               


ch Specify the character to be checked, casted to an int, or EOF.

Return Value

Returns non-zero value (i.e, true) if ch is a hexadecimal digit, else returns zero (i.e, false).


The below example shows the usage of isxdigit() function.

#include <stdio.h>
#include <ctype.h>
int main (){
  char str[] = "ff123YZ";

  //counting the numbers of 
  //hexadecimal digits in str
  int i = 0, count = 0;
  while(str[i]) {

  //displaying the output 
  printf("%s contains %d hexadecimal digits.", str, count);  
  return 0;

The output of the above code will be:

ff123YZ contains 5 hexadecimal digits.

❮ C <ctype.h> Library