1. So, what is isdigit in C?
The isdigit function evaluates an int
value and determines if the value is a digit (0-9).
If the argument is, in fact, a digit, the function
isdigit
returns a non-zero value.
If the argument is not a digit, however, 0 is
returned.
In order to use
this C library function we have to include <ctype.h> header file into our program (e.g.
#include <ctype.h>
).
Example 1: Usage of isdigit.
#
include
<stdio.h>
#
include
<ctype.h>
int
main(
void
)
{
printf
(
"%d\n",
isdigit
(
'a'
));
printf
(
"%d\n",
isdigit
(
'1'
));
return
(
0
);
}
Possible output:
1