1. So, what is isalnum in C?
The isalnum function checks if the passed char
value is in alphabet (a-z, A-Z) or is a digit (0-9), and returns an appropriate value of type int
indicating the result.
If the argument is in alphabet or is a digit
, function
isalnum
returns a non-zero value.
If the argument is not in alphabet and is not a digit, 0 is
returned.
The isalnum function is defined in the <ctype.h> library. This means that in order to use
this function we have to include this header file (e.g.
#include <ctype.h>
).
Example 1: usage of isalnum function in C
#
include
<stdio.h>
#
include
<ctype.h>
int
main(
void
)
{
printf
(
"%d\n",
isalnum
(
'a'
));
printf
(
"%d\n",
isalnum
(
'5'
));
printf
(
"%d\n",
isalnum
(
'+'
));
return
(
0
);
}
Possible output:
1
0