What is iswalnum() in C?

The iswalnum() function checks whether or not the given wide character is an alphanumeric characteruppercase/lowercase letter or decimal digits.

Alphanumeric characters

Library

#include <wctype.h>

Syntax

The function prototype is as follows:

int iswalnum(wint_t ch);

ch: wide character to be checked.

Return Value

The function returns an integer value:

  • If the integer returned is non-zero (true), it means ch is a letter or a digit.
  • If the integer returned is zero (false), it means ch is not a letter or a digit.

Code

#include <stdio.h>
#include <stddef.h>
#include <wctype.h>
#include <wchar.h>
int main ()
{
int i=0;
wchar_t str[] = L"Earth_123!";
while (str[i])
{
if (iswalnum(str[i])) //if a letter or a digit, non-zero(true) value is returned
wprintf (L"%lc is an alphanumeric character\n", str[i]);
else //not a letter and not a digit
wprintf (L"%lc is not an alphanumeric character\n", str[i]);
i++;
}
return 0;
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved