w3resource

C isspace() function

C isspace(int ch)

The isspace() function is used to check whether a character is a space character or not. The function is defined in the ctype.h header file.

Syntax:

int isspace(int argument);

ispunct() Parameters:

Name Description Required /Optional
ch ch is a character of class upper in the current locale. Required

Return value from isupper()

  • The isspace() function return non-zero if ch is a white-space character; otherwise, they shall return 0.

Example: 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:

Input a character: A
The said character is not a white-space character.
--------------------------------
Input a character:
The said character is White-space character.

C Programming Code Editor:

Contribute your code and comments through Disqus.

Previous C Programming: C ispunct()
Next C Programming: C isupper()



Follow us on Facebook and Twitter for latest update.