C++ STL 中的 iswalnum() 函式


C++ STL 中的 iswalnum() 函式檢查給定的寬字元是否為一個字母數字字元,即一個數字 (0-9)、大寫字母 (A-Z)、小寫字母 (a-z) 或任何字母數字字元。

演算法

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

更新於: 30-Jul-2019

149 瀏覽

開啟你的 職業生涯

完成課程,獲得認證

開始學習
廣告
© . All rights reserved.