iswcntrl() function in C/C++

The iswcntrl() is a built-in function in C++ STL which checks if the given wide character is a control character or not. It is defined within the cwctype header file of C/C++.

Syntax:

int iswcntrl(wint_t ch)

Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we have to check that if it is a control character or not.

Return Value: The function returns two values as shown below:

  • If ch is a control character, then a non-zero value is returned.
  • If it is not then it returns 0.

Below programs illustrates the above function.
Program 1:



filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to illustrate the
// iswcntrl() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    wchar_t ch1 = L'\n';
  
    // checks if it is a control character
    if (iswcntrl(ch1))
        wcout << "It is a control Character";
  
    else
        wcout << "It is not a control Character";
    return 0;
}

chevron_right


Output:

It is a control Character

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to illustrate the
// iswcntrl() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    wchar_t ch1 = L'@';
  
    // checks if it is a control character
    if (iswcntrl(ch1))
        wcout << "It is a control Character";
  
    else
        wcout << "It is not a control Character";
  
    return 0;
}

chevron_right


Output:

It is not a control Character


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.