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 鼓励孩子小考祝福语简短