C Data Type Functions - C isalnum






Determines if a character is alphanumeric (A?Z, a?z, 0?9).

Prototype

int isalnum( int ch );

Parameters

ch - character to classify

Return value

Non-zero value if the character is an alphanumeric character, 0 otherwise.

Example


#include <stdio.h>
#include <ctype.h>
#include <locale.h>
 //  w ww  . ja va 2  s .c  om
int main(void)
{
    unsigned char c = '\xdf'; // German letter ? in ISO-8859-1
 
    printf("isalnum('\\xdf') in default C locale returned %d\n", !!isalnum(c));
 
    setlocale(LC_CTYPE, "de_DE.iso88591");
    printf("isalnum('\\xdf') in ISO-8859-1 locale returned %d\n", !!isalnum(c));
}

The code above generates the following result.