Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

isblank() in C/C++

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The isblank()function returns non-zero if ch is a character for which isspace() returns true and is used to separate words. Thus for English, the blank characters are space and horizontal tab.

Header File : 

Declaration : 
int isblank(int ch)

difference between isblank() and isspace()
The isspace() simply return true if the character is a space. In other words blank character is a space character used to separate words within a line of text and isblank() is used to identify it.

isblank() considers blank characters the tab character (‘\t’) and the space character (‘ ‘).
isspace() considers space characters : (‘ ‘) – Space, (‘\t’) – Horizontal tab, (‘\n’) – Newline, (‘\v’) – Vertical tab, (‘\f’) – Feed, (‘\r’) – Carriage return


Input:  Geeks for Geeks
Output: Geeks

Explanation: Since there are 2 spaces for Geeks for Geeks marked by an underscore( _ ) :
we replace the space with a newline character.

isblank() C++ Program:
This code prints out the string character by character, replacing any blank character by a newline.

// CPP program to demonstrate working
// of isblank()
#include <ctype.h>
#include <iostream>
using namespace std;
int main()
    string str = "Geeks for Geeks";
    int i = 0;
    // to store count of blanks
    int count = 0;
    while (str[i]) {
        // to get ith character
        // from string
        char ch = str[i++];
        // mark a new line when space
        // or horizontal tab is found
        if (isblank(ch)) {
            cout << endl;
            cout << ch;
       cout << "\nTotal blanks are : "
            << count << endl;
    return 0;


Total blanks are : 2
My Personal Notes arrow_drop_up
Last Updated : 26 Apr, 2018
Like Article
Save Article
Related Tutorials