Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C isspace()
The isspace() function checks whether a character is a white-space character or not.
If an argument (character) passed to the isspace() function is a white-space character, it returns non-zero integer. If not, it returns 0.
Function prototype of isspace()
int isspace(int argument);
When a character is passed as an argument, corresponding ASCII value (integer) of the character is passed instead of that character itself.
The isspace() function is defined in ctype.h header file.
List of all white-space characters in C programming are:
| Character | Description |
|---|---|
| ' ' | space |
| '\n' | newline |
| '\t' | horizontal tab |
| '\v' | vertical tab |
| '\f' | form feed |
| '\r' | Carriage return |
Example #1: Check white-space character
#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 white-space character.");
}
else
{
printf("White-space character.");
}
return 0;
}
Output
Enter a character: 5 Not a white-space character.
Did you find this article helpful?