C Data Type Functions - C isblank






Checks whether c is a blank character. A blank character is a space character used to separate words within a line of text.

Prototype

int isblank ( int c );

Parameter

This function has the following parameter.

c
Character to be checked, casted to an int, or EOF.

Return

A value different from zero (i.e., true) if indeed c is a blank character. Zero (i.e., false) otherwise.

Example


#include <stdio.h>
#include <ctype.h>
//ww  w  .ja  va 2 s .  c  o  m
int main (){
  char c;
  int i=0;
  char str[]="Example sentence to test isblank\n";
  while (str[i])
  {
    c=str[i];
    if (isblank(c)) c='\n';
    putchar (c);
    i++;
  }
  return 0;
} 

The code above generates the following result.





Example 2


#include <stdio.h>
#include <ctype.h>
#include <limits.h>
 
int main(void)
{
    for (int ndx=0; ndx<=UCHAR_MAX; ndx++)
        if (isblank(ndx)) printf("0x%02x\n", ndx);
}

The code above generates the following result.