The iswcntrl() function is defined in <cwctype> header file.
iswcntrl() prototype
int iswcntrl(wint_t ch);
The iswcntrl() function checks if ch is a control character or not. By default, the characters with the codes from 0x00 to 0x1F and 0x7F are considered control characters.
iswcntrl() Parameters
- ch: The wide character to check.
iswcntrl() Return value
- The iswcntrl() function returns non zero value if ch is a control character.
- It returns zero if ch is not a control character.
Example: How iswcntrl() function works?
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
wchar_t ch1 = L'\u000c';// unicode for form feed
wchar_t ch2 = L'\u03a3';// unicode for Σ
cout << hex << showbase << boolalpha << "iswcntrl(" << (wint_t)ch1 << ") returned " << (bool)iswcntrl(ch1) << endl;
cout << hex << showbase << boolalpha << "iswcntrl(" << (wint_t)ch2 << ") returned " << (bool)iswcntrl(ch2) << endl;
return 0;
}
When you run the program, the output will be:
iswcntrl(0xc) returned true iswcntrl(0x3a3) returned false