isxdigit - C ctype.h

C examples for ctype.h:isxdigit

Type

function

from

<cctype> 
<ctype.h>

Description

Check if character is hexadecimal digit. Hexadecimal digits are any of: 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F

Prototype

int isxdigit ( int c );

Parameters

Parameter Description
cCharacter to be checked, casted to an int, or EOF.

Return Value

A non zero value (i.e., true) if indeed c is a hexadecimal digit. Zero (i.e., false) otherwise.

Demo Code

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()/*from w  w w .ja  va2 s.co  m*/
{
  char str[]="ffff";
  long int number;
  if (isxdigit(str[0]))
  {
    number = strtol (str,NULL,16);
    printf ("The hexadecimal number %lx is %ld.\n",number,number);
  }
  return 0;
}

Related Tutorials