isspace
The isspace
function in C is a standard library function that is used to check whether a given character is a whitespace character. It is defined in the ctype.h
header file. The function takes an integer parameter, which is typically the ASCII value of the character to be checked, and returns a non-zero value if the character is a whitespace character, and 0 otherwise. The function considers the characters ' '
, '\t'
, '\n'
, '\r'
, '\f'
, and '\v'
as whitespace characters.
Here is an example usage of the isspace
function:
#include <stdio.h>
#include <ctype.h>
int main() {
char ch = ' ';
if (isspace(ch)) {
printf("The character is a whitespace character.\n");
} else {
printf("The character is not a whitespace character.\n");
}
return 0;
}
This example checks whether the character ch
is a whitespace character using the isspace
function. If it is, it prints a message indicating that the character is a whitespace character. Otherwise, it prints a message indicating that the character is not a whitespace character.