isspace Function

Test for a white-space character.

Include

<ctype.h>

Prototype

int isspace (int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character, c, is a white-space character; otherwise, returns zero.

Remarks

A character is considered to be a white-space character if it is one of the following: space (' '), form feed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), or vertical tab ('\v').

Example

#include <ctype.h>
#include <stdio.h>

int main(void)
{
  int ch;

  ch = '&';
  if (isspace(ch))
    printf("& is a white-space character\n");
  else
    printf("& is NOT a white-space character\n");

  ch = '\t';
  if (isspace(ch))
    printf("a tab is a white-space character\n");
  else
    printf("a tab is NOT a white-space character\n");
}

Example Output

& is NOT a white-space character
a tab is a white-space character