C programming ctype.h function - int isspace(int c)

https:‮ww//‬w.theitroad.com

The int isspace(int c) function in the ctype.h library of C programming is used to determine whether a given character is a whitespace character.

The isspace() function takes a single integer argument c, which is the character to be checked. The function returns an integer value, which is nonzero if the character is a whitespace character (space, tab, newline, carriage return, form feed, or vertical tab), and zero otherwise.

Here's an example of how to use the isspace() function in C:

#include <stdio.h>
#include <ctype.h>

int main() {
    char c = '\t';
    if (isspace(c)) {
        printf("%c is a whitespace character\n", c);
    } else {
        printf("%c is not a whitespace character\n", c);
    }
    return 0;
}

In this example, the isspace() function is used to check whether the character '\t' (tab) is a whitespace character. Since '\t' is a whitespace character, the function returns a nonzero value, and the output will be: '\t' is a whitespace character'.

If the character had been a non-whitespace character such as 'a', the isspace() function would return zero, and the output would be: 'a' is not a whitespace character'.