Test for an alphanumeric character.
Include
<ctype.h>
Prototype
int isalnum(int c);
Argument
c
Return Value
Returns a non-zero integer value if the character, c
, is
alphanumeric; otherwise, returns a zero.
Remarks
Alphanumeric characters are included within the ranges A-Z, a-z or 0-9.
Example
#include <ctype.h>
#include <stdio.h>
int main(void)
{
int ch;
ch = '3';
if (isalnum(ch))
printf("3 is an alphanumeric\n");
else
printf("3 is NOT an alphanumeric\n");
ch = '#';
if (isalnum(ch))
printf("# is an alphanumeric\n");
else
printf("# is NOT an alphanumeric\n");
}
Example Output
3 is an alphanumeric
# is NOT an alphanumeric