- 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
iswblank() function in C++ STL
The iswblank () function in C++ is used to check if the given wide character is blank not. It is present in “ctype.h” header file in C language and “cctype” header file in C++ Standard template library (STL).
Syntax of iswblank is as follows
int iswblank(wint_t ch)
Return Type − returns non zero value if it contains blank spaces and value 0 if it doesn’t.
Parameters − ch − This is the character to be checked.
Example
Input − string str = “I Love Myself”
Output − total number of spaces is − 2
Input − string str = “Myself”
Output − total number of spaces is − 0
Approach used in the below program is as follows −
Input the string to check whether it contains spaces or not.
Call the function iswblank() and pass the given string to the function as a parameter for the final result.
Catch the non-zero integer value in a variable to print the final result.
Example
#include <ctype.h> #include <iostream> using namespace std; int main(){ setlocale(LC_ALL, "en_US.UTF-8"); wchar_t str[] = L"\u0757\u077c\u0020\u00c5\u00d5\u00dd\u0009\u00a5"; int count = 0; for (int i=0; i<wcslen(str); i++) { if (iswblank(str[i])) count ++; } cout << L"Number of blank characters in \"" << str << "\" = " << count; return 0; }
Output
IF we run the above code it will generate the following output −
Number of blank characters in "ݼݗ ÅÕÝ¥" = 2