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
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短