The C isxdigit function checks whether the given character is hexadecimal or not. The below isxdigit function accept a character as the parameter and find whether that character is hexadecimal or not.
isxdigit(char)
isxdigit in C Programming Example 1
The isxdigit function finds whether the user given character is a hexadecimal character or not.
//Example for isxdigit in C Programming #include <stdio.h> #include <ctype.h> int main() { char ch = '5'; if(isxdigit(ch)) { printf("\nYou have entered a Hexadecimal Character \n"); } else { printf("\n %c is not a Hexadecimal Character", ch); } return 0; }
isxdigit Example 2
This program allows the user to enter any character. Next, it check whether the given character is a hexadecimal or not using the C Programming isxdigit function.
//Example for isxdigit in C Programming #include <stdio.h> #include <ctype.h> int main() { char ch; printf("Please Enter Any Valid Character: "); scanf("%c", &ch); if(isxdigit(ch)) { printf("\nYou have entered a Hexadecimal Character \n"); } else { printf("\n %c is not a Hexadecimal Character", ch); printf("\n I request you to enter a Hexadecimal Character \n"); } return 0; }
OUTPUT
Let me enter another character