C Data Type Functions - C isprint






Determines if a character is printable (decimal 32?126).

Prototype

int isprint( int ch );

Parameters

ch - character to classify

Return value

Non-zero value if the character can be printed, zero otherwise.

Example


#include <stdio.h>
#include <ctype.h>
#include <locale.h>
 /*from   w  ww . j  a va2 s  .c om*/
int main(void){
    unsigned char c = '\xa0'; // the non-breaking space in ISO-8859-1
    printf("In the default C locale, \\xa0 is %sprintable\n", isprint(c)?"":"not ");
    setlocale(LC_ALL, "en_GB.iso88591");
    printf("In ISO-8859-1 locale, \\xa0 is %sprintable\n", isprint(c)?"":"not ");
}

The code above generates the following result.