在本文中,我们将讨论iswgraph()
C ++ STL中函数的工作,语法和示例。
iswgraph()是<cwctype>头文件下的函数。此功能用于检查给定的宽字符是否具有任何图形表示。该函数是函数isgraph的宽字符版本,位于<cctype>头文件下。
可以在屏幕上打印的所有宽字符都是具有图形表示的字符。除转义字符是具有图形表示的字符。
int iswgraph(ch);
该函数仅接受宽字符类型的一个参数ch。
它返回一个整数值,即0是未图形表示的宽字符,而非零值(如果图形表示的宽字符)。
Input: iswgraph(‘?’); Output: It has a graphical representation. Input: iswgraph(‘ ’); Output: It doesn’t have a graphical representation.
#include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch_1 = '%'; wchar_t ch_2 = ')'; if(iswgraph(ch_1)) wcout<< "It has graphical representation: "<<ch_1; else wcout<< "It doesn't have graphical representation: "<<ch_1; if (iswgraph(ch_2)) wcout<< "\nIt has graphical representation: "<<ch_2; else wcout<< "\nIt doesn't have graphical representation: "<<ch_2; return 0; }
输出结果
如果我们运行上面的代码,它将生成以下输出-
It has graphical representation: % It has graphical representation: )
#include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch_1 = '9'; wchar_t ch_2 = '/n'; if(iswgraph(ch_1)) wcout<< "It has graphical representation: "<<ch_1; else wcout<< "It doesn't have graphical representation: "<<ch_1; if (iswgraph(ch_2)) wcout<< "\nIt has graphical representation: "<<ch_2; else wcout<< "\nIt doesn't have graphical representation: "<<ch_2; return 0; }
输出结果
如果我们运行上面的代码,它将生成以下输出-
It has graphical representation: 9 It doesn't have graphical representation: ?