Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

isblank — C23 character classification function

`isblank(c)` from `<ctype.h>` returns a nonzero value for a standard horizontal spacing character or an additional blank character defined by the current locale. In the `C` locale, space and horizontal tab are true; newline is whitespace but is not blank.

Version: C23

Syntax

int isblank(int c);

isblank(c) from <ctype.h> returns a nonzero value for a standard horizontal spacing character or an additional blank character defined by the current locale. In the C locale, space and horizontal tab are true; newline is whitespace but is not blank.

The example tests space, \t, \n, and A in the initial C locale, normalizing results to 0 or 1. Output 1 1 0 0 distinguishes the two horizontal separators from a line ending and a letter.

As with every <ctype.h> function, the argument must be EOF or fit in unsigned char; a negative plain char causes undefined behavior. For a byte use isblank((unsigned char)ch), but preserve EOF separately. Do not equate isblank with isspace: the latter also includes \n, \r, \f, and \v in the C locale; classification of additional bytes depends on LC_CTYPE.

Examples

#include <ctype.h>
#include <stdio.h>
int main(void){int values[]={' ','\t','\n','A'};printf("%d %d %d %d\n",isblank(values[0])!=0,isblank(values[1])!=0,isblank(values[2])!=0,isblank(values[3])!=0);return 0;}

Result

1 1 0 0

The example tests space, `\t`, `\n`, and `A` in the initial `C` locale, normalizing results to 0 or 1. Output `1 1 0 0` distinguishes the two horizontal separators from a line ending and a letter.

Sources