Open In App

iswgraph() in C/C++ with Examples

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:

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.

Below programs illustrates the above function. Program 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;
}

Output:
? has graphical representation 
  does not have graphical representation

Program 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;
}

Output:
does not have graphical representation 
3 has graphical representation

Article Tags :