C++ STL 中的 iswalpha() 函式
C++ STL 中的 iswalpha() 函式用於檢查給定的寬字元是否為字母。
演算法
Begin Initializes the strings. Call function iswalpha(str) to check whether it contains alphabet or not. If it contains alphabet, then value will be returned otherwise zero will be returned. End
示例程式碼
#include <cwctype>
#include <iostream>
#include <cwchar>
#include <clocale>
using namespace std;
int main() {
setlocale(LC_ALL, "ab1234");
wchar_t s[] = L"a%$^^&)";
bool flag = 0;
for (int i=0; i<wcslen(s); i++) {
if (iswalpha(s[i])) {
flag = 1;
break;
}
}
if (flag)
wcout << s << L" contains alphabets";
else
wcout << s << L" doesn't contain alphabets";
return 0;
}輸出
a%$^^&) contains alphabets
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP