Open In App

iswalnum() function in C++ STL

The iswalnum() is a built-in function in C++ STL which checks if the given wide character is an alphanumeric character or not. It is defined within the cwctype header file of C++.
The following characters are alphanumeric:

Syntax:



int iswalnum(ch)

Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we have to check that if it is alphanumeric or not.

Return Value: The function returns two values as shown below.



Below programs illustrates the above function.

Program 1:




// Program to illustrate
// iswalnum() function
#include <cwctype>
#include <iostream>
using namespace std;
  
int main()
{
  
    wchar_t ch1 = '?';
    wchar_t ch2 = 'g';
  
    // Function to check if the character
    // is alphanumeric or not
    if (iswalnum(ch1))
        wcout << ch1 << " is alphanumeric ";
    else
        wcout << ch1 << " is not alphanumeric ";
    wcout << endl;
  
    if (iswalnum(ch2))
        wcout << ch2 << " is alphanumeric ";
    else
        wcout << ch2 << " is not alphanumeric ";
  
    return 0;
}

Output:
? is not alphanumeric 
g is alphanumeric

Program 2:




// Program to illustrate
// iswalnum() function
#include <cwctype>
#include <iostream>
using namespace std;
  
int main()
{
  
    wchar_t ch1 = '3';
    wchar_t ch2 = '&';
  
    // Function to check if the character
    // is alphanumeric or not
    if (iswalnum(ch1))
        wcout << ch1 << " is alphanumeric ";
    else
        wcout << ch1 << " is not alphanumeric ";
    wcout << endl;
  
    if (iswalnum(ch2))
        wcout << ch2 << " is alphanumeric ";
    else
        wcout << ch2 << " is not alphanumeric ";
  
    return 0;
}

Output:
3 is alphanumeric 
& is not alphanumeric

Article Tags :
C++