English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ispace() function checks whether the character is a whitespace character.
If the parameter (character) passed to the ispace() function is a whitespace character, it will return a non-zero integer. If not, it returns 0.
int ispace(int argument);
When a character is passed as an argument, the corresponding ASCII value (integer) of the character is passed, rather than passing the character itself.
The ispace() function inctype.hDefined in header files.
The list of all whitespace characters in C language programming is:
Character | Description |
---|---|
' ' | Space |
'\n' | Newline |
'\t' | Horizontal tab |
'\v' | Vertical tab |
'\f' | Form feed |
'\r' |
#include <stdio.h> #include <ctype.h> int main() { char c; int result; printf("Enter a character: "); scanf("%c", &c); result = isspace(c); if (result == 0) { printf("Not a space character."); } else { printf("Space character."); } return 0; }
Output Result
Enter a character: 5 Not a space character.