Open In App

iswcntrl() function in C/C++

Last Updated : 31 Aug, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

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:




// 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;
}


Output:

It is a control Character

Program 2:




// 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;
}


Output:

It is not a control Character


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads