C++ Standard Library C++ STL Library

C++ <cwctype> - iswblank() Function



The C++ <cwctype> iswblank() function is used to check if the given wide character is a wide blank character. Blank characters are whitespace characters used to separate words within a sentence. In the default "C" locale, only space (L' ', 0x20) and horizontal tab (L'\t', 0x09) are classified as wide blank characters. Other locales may consider a different selection of wide characters as wide blank characters.

Syntax

int iswblank ( wint_t ch ); 

Parameters

ch Specify the wide character to be checked, casted to an wint_t, or WEOF.

Return Value

Returns non-zero value (i.e, true) if ch is a wide blank character, else returns zero (i.e, false).

Example:

The example below shows the usage of iswblank() function.

#include <iostream>
#include <cwchar>
#include <cwctype>
using namespace std;
 
int main (){
  wchar_t str[50] = L"Not to\tbe";

  //replacing the wide blank character
  //with wide new line character in str
  int i = 0;
  while(str[i]) {
    if(iswblank(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:
Not
to
be

❮ C++ <cwctype> Library