isalnum : <ctype.h> library function

isalnum function checks whether a character is an alphanumeric character or not. Alphanumeric characters include set of Digits(0-9), Lowercase letters(a-z) and Uppercase letters(A-Z).

Function prototype of isalnum

int isalnum(int c);
Function isalnum takes a character as input in form of an integer. When we pass a value of type char to isalnum function, corresponding ASCII value of that character is passed.

Return value of isalnum

If passed character is alphanumeric(alphabet or number), then isalnum function returns non-zero integer otherwise 0.

C program to show the use of isalnum function

The following program checks whether a character is alphanumeric or not.

#include <stdio.h>
#include <ctype.h>
#include <conio.h>

int main(){
    char string[] = "1aA*. ;+3";
    int index = 0;
    
    while(string[index] != '\0'){
        if(isalnum(string[index])){
            printf("'%c' is alphanumeric\n", string[index]);
        } else {
            printf("'%c' is not alphanumeric\n", string[index]);
        }
        index++;
    }
    
    getch();
    return 0;
}

Program Output
'1' is alphanumeric
'a' is alphanumeric
'A' is alphanumeric
'*' is not alphanumeric
'.' is not alphanumeric
' ' is not alphanumeric
';' is not alphanumeric
'+' is not alphanumeric
'3' is alphanumeric