totn C Functions

C Language: isxdigit function
(Test for Hexadecimal Digit)

In the C Programming Language, the isxdigit function tests whether c is a hexadecimal digit.

Syntax

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

int isxdigit(int c);

Parameters or Arguments

c
The value to test whether 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 not 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 look at an example to see how you would use the isxdigit function 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 similar to the isxdigit function: