C examples for ctype.h:isxdigit
function
<cctype> <ctype.h>
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
int isxdigit ( int c );
Parameter | Description |
---|---|
c | Character to be checked, casted to an int, or EOF. |
A non zero value (i.e., true) if indeed c is a hexadecimal digit. Zero (i.e., false) otherwise.
#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; }