C isxdigit() - C Standard Library (2024)

The function prototype of isxdigit() is:

int isxdigit( int arg );

It is defined in the <ctype.h> header file.

isxdigit() Parameters

The isxdigit() function takes a single character as a parameter.

Note: In C programming, characters are treated as int values internally.

C isxdigit() Return Value

If the argument passed to isxdigit() is

  • a hexadecimal character, isxdigit() returns a non-zero integer.
  • a non-hexadecimal character, isxdigit() returns 0.

Example 1: C isxdigit() function

#include <ctype.h>#include <stdio.h>int main() { char c = '5'; int result; // hexadecimal character is passed result = isxdigit(c); // result is non-zero printf("Result when %c is passed to isxdigit(): %d", c, isxdigit(c)); c = 'M'; // non-hexadecimal character is passed result = isxdigit(c); // result is 0 printf("\nResult when %c is passed to isxdigit(): %d", c, isxdigit(c)); return 0;}

Output

Result when 5 is passed to isxdigit(): 128Result when M is passed to isxdigit(): 0

Example 2: Program to Check Hexadecimal Character

#include <ctype.h>#include <stdio.h>int main() { char c = '5'; printf("Enter a character: "); c = getchar(); if (isxdigit(c) != 0) { printf("%c is a hexadecimal character.", c); } else { printf("%c is not a hexadecimal character.", c); } return 0;}

Output

Enter a character: ff is a hexadecimal character.
C isxdigit() - C Standard Library (2024)

FAQs

C isxdigit() - C Standard Library? ›

int isxdigit( int ch ); Checks if the given character is a hexadecimal numeric character (0123456789abcdefABCDEF) or is classified as a hexadecimal character. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

What is isxdigit in C programming? ›

int isxdigit( int ch ); Checks if the given character is a hexadecimal numeric character (0123456789abcdefABCDEF) or is classified as a hexadecimal character. The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

What library is isdigit in C? ›

The C ctype library isdigit() function checks if the passed character is a decimal digit character.

What is the C standard library? ›

C Standard library functions or simply C Library functions are inbuilt functions in C programming. The prototype and data definitions of these functions are present in their respective header files. To use these functions we need to include the header file in our program.

What library is strcmp in C? ›

In POSIX and in the programming language C, strcmp is a function in the C standard library (declared in string. h ) that compares two C strings.

How to randomize data in C? ›

Random number in C is often generated using rand() and srand() functions. Both of them are often used together. To mimic randomness in a number we pass time as a seed in srand() function.

How to check if a string is hexadecimal in C? ›

Below are the steps to solve the problem:
  1. Iterate over the given string.
  2. Check if each character of the string is between characters A to F or between 0 and 9.
  3. If found to be true, then print Yes.
  4. Otherwise, print No.
Nov 23, 2023

How does isdigit() work in C? ›

The isdigit() in C is a function that can be used to check if the passed character is a digit or not. It returns a non-zero value if it's a digit else it returns 0. For example, it returns a non-zero value for '0' to '9' and zero for others. The isdigit() function is declared inside ctype.

What is an example of a standard library function? ›

Some of the common standard library functions in C include:

Examples include printf(), scanf(), and gets(). String manipulation functions: These string manipulation functions are used to manipulate strings in C. Examples include strlen(), strcpy(), and strcat().

How to find C libraries? ›

Libaries consist of a set of related functions to perform a common task; for example, the standard C library, 'libc. a', is automatically linked into your programs by the “gcc” compiler and can be found at /usr/lib/libc. a. Standard system libraries are usually found in /lib and /usr/lib/ directories.

What are the most used C standard libraries? ›

The most commonly used libraries are libc and libm. The libc library is the Standard C library that includes everything but the math library; libm is the math library.

Where is standard C library stored? ›

The C source files for the standard library could be anywhere - and probably aren't stored on your computer at all. The binary files are stored in libraries - which on a Linux/Unix computer would probably be in /lib or /usr/lib - on a Windows machine, they'll probably be “.

What is the difference between C standard library and C runtime library? ›

For example, the C programming language requires only a minimal runtime library (commonly called crt0 ), but defines a large standard library (called C standard library) that has to be provided by each implementation.

What library is string in C? ›

C Library – <string. h> string. h is a standard header file in the C language that contains functions for manipulating strings (arrays of characters).

What can I use instead of strcmp in C? ›

In locales for which the character set and the lexicographic character order differ, you can use strcoll instead of strcmp for lexicographic comparison of strings. Alternatively, you can use strxfrm on the original strings, and then use strcmp on the resulting strings.

What is strcmp () and Strncmp () in C? ›

Output strcmp: compares each character "abcdefg" is less than "abcfg" strncmp: compares only the first 3 characters first 3 characters of "abcdefg" is identical to "abcfg"

What is the meaning of regex in C? ›

regex is a pointer to a memory location where expression is matched and stored. expression is a string type. flag to specify the type of compilation.

What is the function of hexadecimal in C? ›

In C there is no data type to store hexadecimal values like float or long or double instead you can store in the integral type of data types. In C programming language, hexadecimal value is represented as 0x or 0X and to input hexadecimal value using scanf which has format specifiers like %x or %X.

What is decompiler in C? ›

A C decompiler converts an executable (the output from a C com- piler) into source code. The recovered C source code, once re- compiled, is expected to produce an executable with the same functionality as the original executable.

How to do repetition in C? ›

for Loop. for loop in C programming is a repetition control structure that allows programmers to write a loop that will be executed a specific number of times. for loop enables programmers to perform n number of steps together in a single line. In for loop, a loop variable is used to control the loop.

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6352

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.