C++ <cwctype> - iswspace() Function
The C++ <cwctype> iswspace() function is used to check if the given wide character is a wide whitespace character. In the default "C" locale, the wide whitespace characters are the following:
- Space (L' ', 0x20)
- Feed (L'\f', 0x0c)
- Newline (L'\n', 0x0a)
- Carriage return (L'\r', 0x0d)
- Horizontal tab (L'\t', 0x09)
- Vertical tab (L'\v', 0x0b)
Other locales may consider a different selection of wide characters as wide whitespace characters.
Syntax
int iswspace ( wint_t ch );
Parameters
Return Value
Returns non-zero value (i.e, true) if ch is a wide whitespace character, else returns zero (i.e, false).
Example:
The example below shows the usage of iswspace() function.
#include <iostream> #include <cwchar> #include <cwctype> using namespace std; int main (){ wchar_t str[50] = L"To\rbe,\nor not to\tbe"; //replacing the wide whitespace character //with wide new line character in str int i = 0; while(str[i]) { if(iswspace(str[i])) str[i] = L'\n'; i++; } //displaying the output wcout<<"str contains:\n"<<str; return 0; }
The output of the above code will be:
str contains: To be, or not to be
❮ C++ <cwctype> Library