You are here : cpp0isdigit

isdigit() - 0

The C library function void 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.
This function returns non-zero value if c is a digit, else it returns 0.


Syntax

int isdigit(int c);


Example

#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);
}


Output / Return Value

var1 = |h| is not a digit
var2 = |2| is a digit


Limitations


Alternatives / See Also


Reference