C++ cctype isxdigit() Function
Example
Check if a character is a hexadecimal digit:
char c = 'F';
if (isxdigit(c)) {
cout << c << " is a hexadecimal digit";
} else {
cout << c << " is not a hexadecimal digit";
}
Definition and Usage
The isxdigit() function checks if a character is a hexadecimal digit. Hexadecimal is a number system with 16 digits: 0 to 9, and the letters A to F (uppercase or lowercase).
It returns a non-zero number (true) if it is, and 0 (false) if it is not. For example, F is a hexadecimal digit, but G is not.
The isxdigit function is defined in the <cctype> header file.
Syntax
int isxdigit(int c);
Parameter Values
| Parameter | Description |
|---|---|
| c | Required. The character to check. |
Technical Details
| Returns: | An int value. Non-zero (true) if the character is a hexadecimal digit, otherwise 0 (false). |
|---|
Related Pages
Read more about strings in our Strings Tutorial.