Popular Tutorials
Start Learning C++Certification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C++ isblank()
The isblank() function in C++ checks if the given character is a blank character or not.
isblank() Prototype
int isblank(int ch);
The isblank() function checks if ch is a blank character or not as classified by the currently installed C locale. By default, space and horizontal tab are considered as blank characters.
The behaviour of isblank() is undefined if the value of ch is not representable as unsigned char or is not equal to EOF.
It is defined in <cctype> header file.
isblank() Parameters
ch: The character to check.
isblank() Return value
The isblank() function returns non zero value if ch is a blank character, otherwise returns zero.
Example: How isblank() function works
#include <cctype>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str[] = "Hello, I am here.";
int count = 0;
for (int i=0; i<=strlen(str); i++)
{
if (isblank(str[i]))
count ++;
}
cout << "Number of blank characters: " << count << endl;
return 0;
}
When you run the program, the output will be:
Number of blank characters: 3
Did you find this article helpful?