The iswgraph() is a built-in function in C/C++ which checks if the given wide character has a graphical representation or not. It is defined within the cwctype header file of C++. By default, the following characters are graphic:
- Digits (0 to 9)
- Uppercase letters (A to Z)
- Lowercase letters (a to z)
- Punctuation characters (!”#$%&'()*+, -./:;?@[\]^_`{|}~)
Syntax:
int iswgraph(ch)
Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we have to check that if it has a graphical representation or not. Return Value: The function returns two values as shown below.
- If the ch has a graphical representation character, then a non-zero value is returned.
- If it is not a graphical representation character, then 0 is returned.
Below programs illustrates the above function. Program 1:
CPP
// 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;
} |
Output:
? has graphical representation does not have graphical representation
Program 2:
CPP
// 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;
} |
Output:
does not have graphical representation 3 has graphical representation