
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
- Related Articles
- sinh() function in C++ STL
- cosh() function in C++ STL
- atanh() function in C++ STL
- tanh() function in C++ STL
- acosh() function in C++ STL
- asinh() function in C++ STL
- acos() function in C++ STL
- atan2() function in C++ STL
- iswalnum() function in C++ STL
- iswalpha() function in C++ STL
- lldiv() function in C++ STL
- negate function in C++ STL
- iswblank() function in C++ STL
- iswcntrl() function in C++ STL
- iswdigit() function in C++ STL
