isprint() function of ctype.h in C

In this article, we are going to learn about the isprint() function of ctype.h header file in C programming language and use it to identify the printing characters.
Submitted by Abhishek Sharma, on April 10, 2018

This function takes a parameter of a character and checks if the character is a printing (printable) character or not. The function returns ‘zero’ if the character is not a printing character and ‘one’ if the character is a printing character.

Using this function is rather simple because all it takes is a character of type char and returns an integer. The Value of integer determines if the character is a printing character or not.

This function can be used to identify the non printing characters inside the array of characters or user’s input at a certain point.


    Input character is: ‘a’
    Function will return 1

    Input character is: 0
    Function will return 0

ctype.h - isprint() function Example in C

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

int main()
	// defining the type of variable
	char a;
	int b;

	// assigning the value of variable
	a = 'A';
	b = 0;

	// condition to test the printing characters
	if (isprint(a) != 0)
		printf("%c is a printing character\n\n", a);
		printf("%c is not a printing character\n\n", a);

	if (isprint(b) != 0)
		printf("NULL is a printing character\n");
		printf("NULL is not a printing character\n");

	return 0;


ctype.h - isprint()  in c language

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.