iswgraph()是C /C++中的内置函数,该函数检查给定的宽字符是否具有图形表示。它在C++的cwctype头文件中定义。默认情况下,以下字符是图形:
- 位数(0至9)
- 大写字母(从A到Z)
- 小写字母(a至z)
- 标点符号(!”#$%&'()* +,-./:;?@[\]^_`{|}~)
用法:
int iswgraph(ch)
参数:该函数接受单个强制性参数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
相关用法
- C++ cin get()用法及代码示例
- C++ iswprint()用法及代码示例
- C++ cauchy_distribution a()用法及代码示例
- C++ ios eof()用法及代码示例
- C++ ios bad()用法及代码示例
- C++ ratio_equal()用法及代码示例
注:本文由纯净天空筛选整理自IshwarGupta大神的英文原创作品 iswgraph() in C/C++ with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。