C Standard Library

C <ctype.h> - isblank() Function



The C <ctype.h> isblank() function is used to check if the given character is a blank character. Blank characters are whitespace characters used to separate words within a sentence. In the default "C" locale, only space (' ', 0x20) and horizontal tab ('\t', 0x09) are classified as blank characters. Other locales may consider a different selection of characters as blank characters.

Syntax

int isblank ( int ch ); 

Parameters

ch Specify the character to be checked, casted to an int, or EOF.

Return Value

Returns non-zero value (i.e, true) if ch is a blank character, else returns zero (i.e, false).

Example:

The example below shows the usage of isblank() function.

#include <stdio.h>
#include <ctype.h>
 
int main (){
  char str[50] = "Not to\tbe";

  //replacing the blank character
  //with new line character in str
  int i = 0;
  while(str[i]) {
    if(isblank(str[i]))
      str[i] = '\n';
    i++;
  }

  //displaying the output
  printf("str contains:\n%s", str);  
  return 0;
}

The output of the above code will be:

str contains:
Not
to
be

❮ C <ctype.h> Library