C++ STL中的函数

这个 伊斯瓦尔法() 是C++中的一个内置函数,它检查给定的宽字符是否是字母表。它是在 cwctype C++的头文件。

null

以下字符为字母数字:

  • 大写字母 :A到Z
  • 小写字母 :a到z

语法 :

int iswalpha(ch)

参数 :该函数接受一个强制参数 中国 它指定了宽字符,我们必须检查它是否是字母表。

返回值 :函数返回两个值:

  • 如果ch是字母数字字符,则返回非零值。
  • 如果不是字母数字字符,则返回0。

下面的程序说明了上述功能。

方案1 :

// Program to illustrate
// iswalpha() function
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
wchar_t ch1 = 'Q' ;
wchar_t ch2 = 'g' ;
iswalpha(ch1) ? wcout << ch1
<< "is alphabet " : wcout << ch1
<< " is not alphabet " ;
wcout << endl;
iswalpha(ch2) ? wcout << ch2
<< " is an alphabet " : wcout << ch2
<< " is not an alphabet " ;
return 0;
}


输出:

Q is an alphabet 
g is an alphabet

方案2 :

// Program to illustrate
// iswalpha() function
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
wchar_t ch1 = 'w' ;
wchar_t ch2 = '2' ;
iswalpha(ch1) ? wcout << ch1 <<
" is alphabet " : wcout << ch1
<< " is not alphabet " ;
wcout << endl;
iswalpha(ch2) ? wcout << ch2 <<
" is an alphabet " : wcout << ch2
<< " is not an alphabet " ;
return 0;
}


输出:

w is an alphabet 
2 is not an alphabet

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享