Home » C programs » ctype.h header file functions

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.

Example:

    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);
	}
	else
	{
		printf("%c is not a printing character\n\n", a);
	}

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

	return 0;
}

Output

ctype.h - isprint()  in c language






Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.