Name

isalnum

Synopsis

Ascertains whether a given character is alphanumeric

#include <ctype.h>
intisalnum( int c );

The function isalnum() tests whether its character argument is alphanumeric; that is, whether the character is either a letter of the alphabet or a digit. In other words, isalnum() is true for all characters for which either isalpha() or isdigit() is true.

Which characters are considered alphabetic or numeric depends on the current locale setting for the localization category LC_CTYPE, which you can query or change using the setlocale() function.

If the character is alphanumeric, isalnum() returns a nonzero value (that is, true); if not, the function returns 0 (false).

Example

See the example for isprint() in this chapter.

See Also

isalpha(), isblank(), iscntrl(), isdigit(), isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(), isxdigit(); the corresponding C99 function for wide characters, iswalnum(); setlocale()

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.