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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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;
}
chevron_right

Output:
? is not alphanumeric 
g is alphanumeric

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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;
}
chevron_right

Output:
3 is alphanumeric 
& is not alphanumeric



Budding Web DeveloperKeen learnerAverage CoderDancer&Social Activist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
C++
Practice Tags :