6.3.10 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
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#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