C programming isspace ctype.h


In C the <ctype.h> isspace function test if the character is a standard white-space character or any locale specific character for which ‘isalnum’ is false.In “C” locale the standard white-space character are the following: space(‘ ‘),form feed(‘\f’),new-line(‘\n’), carriage return(‘\r’),horizontal tab(‘\t’),and vertical tab(‘\v’).The declaration of the function is given below.

Link :C isalnum

int isspace(int c);

Parameters:
c -The character to be tested for standard white-space.

Return type
int -Return non-zero value if the argument is a white-space.

In passing integer value as the argument only the integer from the range [9,13] and 32 will be returned true by ‘isspace’,since 9 represent horizontal tab(‘\t’) , 10 represent new line(‘\n’),11 represent vertcal tab(‘\t’) ,12 represent from feed(‘\f’),13 represent carriage return(‘\r’) and 32 represent the space(‘ ‘).

Code example

printf(“%d” , isspace(‘\n’) );

printf(“\n%d” , isspace(‘\r’) );

printf(“\n%d” , isspace(9) );

printf(“\n%d” , isspace(11) );

printf(“\n%d” , isspace(8) );

printf(“\n%d” , isspace( ‘,’) );

Output,

8
8
8
8
0
0


Related links

->C isblank

->C iscntrl

->C isgraph

->C isupper