C programming isdigit ctype.h

In C programming the <ctype.h> isdigit function test the value for any decimal-digit character.The declaration of the function is shown below.

int isdigit(int c);

c -The integer value to be tested for decimal type.

Return type
int -Returns non-zero value only if the argument is decimal digit.
Note this function returns true only for the integer value between 48 to 57 because these integer values when mapping to ASCII chart gives the digit 0 to 9.If you pass any other values besides from the range [48,57] the function will always return 0-false.
Code example

int ret;


printf(“\nret=%d” , ret);

ret=isdigit(256+57); //VS gives debug assertion failure here

printf(“\nret=%d” , ret);

printf(“%c , %c” , 57 ,256+57);


9 , 9

Here 57 and 256+57(313) map to the integer value ‘9’ in ASCII chart but only when passing 57 as argument seems to return true.In Visual Studio only integer between -1 and 255 is accepted as argument,if any other value is passed it throws ‘debug assertion fail!’ message.

Related links

->C isalnum ctype.h

->C isalpha ctype.h

->C isupper

->C isxdigit

->C toupper ctype.h