📜  C++ iswalnum()

📅  最后修改于: 2020-09-25 10:19:08             🧑  作者: Mango

C++中的iswalnum() 函数检查给定的宽字符是否为字母数字字符 。

iswalnum() 函数在头文件中定义。

iswalnum()原型

int iswalnum(wint_t ch);

iswalnum() 函数检查ch是否为字母数字字符 。以下字符是字母数字:

iswalnum()参数

iswalnum()返回值

示例:iswalnum() 函数如何工作?

#include 
#include 
#include 
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;
}

运行该程序时,输出为:

In the current locale
¶ is not alphanumeric
Å is alphanumeric