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.

  • It returns a non-zero value if the parameter ch, is a wide whitespace.
  • It returns 0 if it is not a lowercase character.

Below programs illustrates the above function.

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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 th 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;
}

chevron_right


Output:

Geeks
For
Geeks

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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 th 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;
}

chevron_right


Output:

Hello
Ishwar
Gupta


My Personal Notes arrow_drop_up

Budding Web DeveloperKeen learnerAverage CoderDancer&Social Activist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.