isxdigit function(Test for Hexadecimal Digit) in C Language – example and detail

In the C Programming Language, the isxdigit feature assessments whether or not c is a hexadecimal digit.

Syntax

The syntax for the isxdigit characteristic in the C Language is:

int isxdigit(int c);

Parameters or Arguments

c The value to check whether or not it is a hexadecimal digit.

Returns

The isxdigit function returns a nonzero value if c is a hexadecimal digit and returns zero if c is no longer a hexadecimal digit.

Required Header

In the C Language, the required header for the isxdigit function is:

#include <ctype.h>

Applies To

In the C Language, the isxdigit function can be used in the following versions:

ANSI/ISO 9899-1990

isxdigit Example

Let’s seem to be at an instance to see how you would use the isxdigit feature in a C program:

/* Example using isxdigit by TechOnTheNet.com */

#include <stdio.h>
#include <ctype.h>

int main(int argc, const char * argv[])
{
    /* Define a string to be tested */
    char value1 = 'a';
    char value2 = 't';

    /* Test to see if the first value contains hexideciaml values */
    if (isxdigit(value1))
        printf("%c is hexadecimal\n", value1);
    else
        printf("%c is not hexadecimal\n", value1);

    /* Test to see if the second string contains hexideciaml values */
    if (isxdigit(value2))
        printf("%c is hexadecimal\n", value2);
    else
        printf("%c is not hexadecimal\n", value2);

    return 0;
}

When compiled and run, this application will output:

a is hexadecimal
t is not hexadecimal

Similar Functions

Other C functions that are comparable to the isxdigit function:

isdigit function <ctype.h>