isprint : <ctype.h> library function

isprint function checks whether a character is printable character or not. A printable character is a character that occupies a printing position on a display we may also define it as a character that is not a control character.

Function prototype of isprint

int isprint(int c);
Function isprint() takes a character as input in form of an integer. When we pass a value of type char to isprint function, corresponding ASCII value of that character is passed.

Return value of isprint

If passed character is a printable character, then isprint function returns non-zero(true) integer otherwise 0(false).

C program to show the use of isprint function

The following program is to check whether a character is printable character or not.

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

int main(){
    char string[] = "Aa. \t1\n";
    int index = 0;
    
    while(string[index] != '\0'){
        if(isprint(string[index])){
            printf("'%c' is a printable character\n", string[index]);
        } else {
            printf("'%c' is not a printable character\n", string[index]);
        }
        index++;
    }
    
    getch();
    return 0;
}

Program Output
'A' is a printable character
'a' is a printable character
'.' is a printable character
' ' is a printable character
'        ' is not a printable character
'1' is a printable character
'
' is not a printable character