- 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
iswspace() function in C++ STL
In this article we are going to discuss the iswspace() function in C++, its syntax, working and its return values.
iswspace() function is an inbuilt function in C++ which is defined in header file. The function checks whether the passed wide character is a white space character or not.This function is a wide character equivalent of isspace(), which means it works the same as isspace() the difference is it supports a wide character. The function checks the if argument passed is a white space (‘ ‘) then return a non-zero integer value(true), else return zero(false)
Syntax
int iswspace(wint_t ch);
The function accepts only one parameter, i.e. a wide character which is to be checked. The argument is casted in wint_t or WEOF.
wint_t stores an integral type of data.
Return value
The function returns an integer value, which can be either 0 (in case of false) or any non-zero value(in case of true).
Example
#include <iostream> #include <cwctype> using namespace std; int main() { wint_t a = '.'; wint_t b = ' '; wint_t c = '1'; iswspace(a)?cout<<"\nIts white space character":cout<<"\nNot white space character"; iswspace(b)?cout<<"\nIts white space character":cout<<"\nNot white space character"; iswspace(c)?cout<<"\nIts white space character":cout<<"\nNot white space character"; }
Output
If we run the above code it will generate the following output −
Not white space character Its white space character Not white space character
Example
#include <iostream> #include <cwctype> using namespace std; int main () { int i, count; wchar_t s[] = L"I am visiting tutorials point"; count = i = 0; while (s[i]) { if(iswspace(s[i])) count++; i++; } cout<<"There are "<<count <<" white space characters.\n"; return 0; }
Output
If we run the above code it will generate the following output −
There are 4 white space characters.