C++ <cwctype> - iswcntrl() Function
The C++ <cwctype> iswcntrl() function is used to check if the given wide character is a control character. A control character is a character that does not occupy a printing position on a display. In the default "C" locale, a control character are those between ASCII codes 0x00 (NUL) and 0x1f (US), plus 0x7f (DEL).
Other locales may consider a different selection of wide characters as control characters.
Syntax
int iswcntrl ( wint_t ch );
Parameters
Return Value
Returns non-zero value (i.e, true) if ch is a control character, else returns zero (i.e, false).
Example:
The example below shows the usage of iswcntrl() function.
#include <iostream> #include <cwchar> #include <cwctype> using namespace std; int main (){ wchar_t str[50] = L"Hello\nWorld!"; //replacing all wide control //characters with @ in str int i = 0; while(str[i]) { if(iswcntrl(str[i])) str[i] = L'@'; i++; } //displaying the output wcout<<"str contains: "<<str; return 0; }
The output of the above code will be:
str contains: Hello@World!
❮ C++ <cwctype> Library