Open In App

iswspace() function in C/C++

The iswspace() is a built-in function in C/C++ which checks if the given wide character is a wide whitespace character or not. It is defined within the cwctype header file of C++. Syntax:

int iswspace(ch)

Parameters: The function accepts a single mandatory parameter ch which specifies the wide character which is to be checked for a wide whitespace character or not. Return Value: The function returns two values as shown below.

Below programs illustrates the above function. Program 1




// C++ program to illustrate
// iswspace() function
#include <cwctype>
#include <iostream>
using namespace std;
 
int main()
{
    wchar_t c;
    int i = 0;
    wchar_t str[] = L"Geeks For Geeks\n";
 
    // Check for every character
    // in the string
    while (str[i]) {
        c = str[i];
 
        // Function to check the character
        // is a wide whitespace or not
        if (iswspace(c))
            c = L'\n';
        putwchar(c);
        i++;
    }
    return 0;
}

Output:
Geeks
For
Geeks

Program 2




// C++ program to illustrate
// iswspace() function
#include <cwctype>
#include <iostream>
using namespace std;
 
int main()
{
    wchar_t c;
    int i = 0;
    wchar_t str[] = L"Hello Ishwar Gupta\n";
 
    // Check for every character
    // in the string
    while (str[i]) {
        c = str[i];
        // Function to check the character
        // is a wide whitespace or not
        if (iswspace(c))
            c = L'\n';
        putwchar(c);
        i++;
    }
    return 0;
}

Output:
Hello
Ishwar
Gupta

Article Tags :
C++