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:
CPP
// 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"Beginner For Beginner\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:
Beginner For Beginner
Program 2:
CPP
// 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