iswblank() function in C/C++



The function iswblank() is used to check that the passed wide character is blank or not. It is basically a space character and it also considers tab character(\t). This function is declared in “ctype.h” header file in C language and “cctype”” header file in C++ language.

Here is the syntax of isblank() in C++ language,

int iswblank(wint_t char);

Here is an example of iswblank() in C++ language,

Example

 Live Demo

#include <ctype.h> #include <iostream> using namespace std; int main() {    wchar_t s[] = L"The space between words.";    int i = 0;    int count = 0;    while(s[i]) {       char c = s[i++];       if (iswblank(c)) {          count++;       }    }    cout << "\nNumber of blanks in sentence : " << count << endl;    return 0; }

Output

Number of blanks in sentence : 5

In the above program, a string is passed in variable s. The function iswblank() is used to check the spaces or blanks in the passed string as shown in the following code snippet.

wchar_t s[] = L"The space between words."; int i = 0; int count = 0; while(s[i]) {    char c = s[i++];    if (iswblank(c)) {       count++;    } }
Updated on: 2020-06-26T07:55:24+05:30

214 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements