- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
iswcntrl() function in C++ STL
The iswcntrl () function in C++ standard template library(STL) is used to check if the given wide character is a control character or not. A control character is a character in C/C++ that won’t occupy a printing position on a display screen. Iswcntrl() function is defined in a cwctype header file.
Syntax of iswcntrl() function is as follows
int iswcntrl (wint_t c)
Parameters − c − This is the character to be checked.
Return Value − A value different from zero (i.e.. a non-zero value) if c is a control character else a zero value.
Approach used in the below program is as follows
- Input the string or character from the user
- Traverse the loop till the control character is not found
- Display the string till the first control character is not found
- Exit from the loop when the first control character is examined
Example-1
#include <stdio.h> #include <wctype.h> int main (){ int i=0; wchar_t str[] = L"first line \n second line \n"; while (!iswcntrl(str[i])) { putchar (str[i]); i++; } return 0; }
Output
If we run the above code it will generate the following output −
First line
Example-2
#include <stdio.h> #include <wctype.h> int main (){ int i=0; wchar_t str[] = L"first linesecond line \nthird line"; while (!iswcntrl(str[i])) { putchar (str[i]); i++; } return 0; }
Output
If we run the above code it will generate the following output −
First linesecond line
Advertisements