- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - isdigit()
Description
The C library function int isdigit(int c) checks if the passed character is a decimal digit character.
Decimal digits are (numbers) − 0 1 2 3 4 5 6 7 8 9.
Declaration
Following is the declaration for isdigit() function.
int isdigit(int c);
Parameters
c − This is the character to be checked.
Return Value
This function returns non-zero value if c is a digit, else it returns 0.
Example
The following example shows the usage of isdigit() function.
#include <stdio.h> #include <ctype.h> int main () { int var1 = 'h'; int var2 = '2'; if( isdigit(var1) ) { printf("var1 = |%c| is a digit\n", var1 ); } else { printf("var1 = |%c| is not a digit\n", var1 ); } if( isdigit(var2) ) { printf("var2 = |%c| is a digit\n", var2 ); } else { printf("var2 = |%c| is not a digit\n", var2 ); } return(0); }
Let us compile and run the above program, to produce the following result −
var1 = |h| is not a digit var2 = |2| is a digit
ctype_h.htm
Advertisements