isspace() function in C

isspace() function in C

Using the isspace() function in C

The isspace() function in C is used to check whether a character is a space. The function takes a character as input and returns a non-zero value if the character is a space, or zero if the character is not a space.

Here is an example of how to use the isspace() function:

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

int32_t main(int32_t argc, char const *argv[])
{
    char c = ' ';

    int32_t result = isspace(c);

    if (result > 0x00)
    {
        printf("The character '%c' is a space.\n", c);
    }
    else
    {
        printf("The character '%c' is not a space.\n", c);
    }

    return 0;
}

The isspace() function takes a character as input and returns a non-zero value if the character is a space, or zero if the character is not a space. In this example, the character ' ' is a space, so the function will return a non-zero value and the printf() statement will print the output.

Explore the complete list of functions available in ctype header in C standard library.