这个 iswgraph() 是C/C++中的一个内置函数,用于检查给定的宽字符是否具有图形表示形式。它是在 cwctype C++的头文件。默认情况下,以下字符是图形:
null
- 数字 (0至9)
- 大写字母 (A至Z)
- 小写字母 (a至z)
- 标点符号 (!”#$%&'()*+, -./:;?@[]^_`{|}~)
语法 :
int iswgraph(ch)
参数 :该函数接受一个强制参数 中国 它指定了宽字符,我们必须检查它是否有图形表示。
返回值 :该函数返回两个值,如下所示。
- 如果ch具有图形表示字符,则返回非零值。
- 如果不是图形表示字符,则返回0。
下面的程序说明了上述功能。
方案1 :
// C++ program to illustrate // iswgraph() function #include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch1 = '?' ; wchar_t ch2 = ' ' ; // Function to check if the character // has a graphical representation or not if (iswgraph(ch1)) wcout << ch1 << " has graphical representation " ; else wcout << ch1 << " does not have graphical representation " ; wcout << endl; if (iswgraph(ch2)) wcout << ch2 << " has graphical representation " ; else wcout << ch2 << " does not have graphical representation " ; return 0; } |
输出:
? has graphical representation does not have graphical representation
方案2 :
// C++ program to illustrate // iswgraph() function #include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch1 = ' ' ; wchar_t ch2 = '3' ; // Function to check if the character // has a graphical representation or not if (iswgraph(ch1)) wcout << ch1 << " has graphical representation " ; else wcout << ch1 << " does not have graphical representation " ; wcout << endl; if (iswgraph(ch2)) wcout << ch2 << " has graphical representation " ; else wcout << ch2 << " does not have graphical representation " ; return 0; } |
输出:
does not have graphical representation 3 has graphical representation
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END