The iswalnum() function is defined in <cwctype> header file.
iswalnum() prototype
int iswalnum(wint_t ch);
The iswalnum() function checks if ch is an alphanumeric character or not. The following characters are alphanumeric:
- Uppercase letters: A to Z
- Lowercase letters: a to z
- Digits: 0 to 9
iswalnum() Parameters
- ch: The wide character to check.
iswalnum() Return value
- The iswalnum() function returns non zero value if ch is an alphanumeric character.
- It returns zero if ch is not an alphanumeric character.
Example: How iswalnum() function works?
#include <cwctype>
#include <iostream>
#include <clocale>
using namespace std;
int main()
{
setlocale(LC_ALL, "en_US.UTF-8");
wchar_t wc1 = L'\u00b6';
wchar_t wc2 = L'\u00c5';
wcout << L"In the current locale" << endl;
iswalnum(wc1)?wcout << wc1 << " is alphanumeric ":wcout << wc1 << " is not alphanumeric ";
wcout << endl;
iswalnum(wc2)?wcout << wc2 << " is alphanumeric ":wcout << wc2 << " is not alphanumeric ";
return 0;
}
When you run the program, the output will be:
In the current locale ¶ is not alphanumeric Å is alphanumeric