iswalnum() function ใน C++ STL ตรวจสอบว่า wide character ที่กำหนดเป็น alphanumeric character หรือไม่ กล่าวคือ ตัวเลข (0-9), ตัวพิมพ์ใหญ่ (A-Z), ตัวพิมพ์เล็ก (a-z) หรือ alphanumeric character อื่นๆ
Algorithm
Begin Initializes the characters. Call function iswalnum(c1) to check whether it is alphanumeric or not. If it is alphanumeric character, then value will be returned otherwise zero will be returned. End
ตัวอย่างโค้ด
#include <cwctype>
#include <iostream>
using namespace std;
int main() {
wchar_t c1 = '/';
wchar_t c2 = 'a';
if (iswalnum(c1))
wcout << c1 << " is alphanumeric ";
else
wcout << c1 << " is not alphanumeric ";
wcout << endl;
if (iswalnum(c2))
wcout << c2 << " is alphanumeric ";
else
wcout << c2 << " is not alphanumeric ";
return 0;
}
ผลลัพธ์
/ is not alphanumeric a is alphanumeric