Home » C programs » ctype.h header file functions

isgraph() function of ctype.h in C



In this article, we are going to learn about the use isgraph() function of ctype.h header file in C language and use it to check NULL condition.
Submitted by Manu Jemini, on April 04, 2018

We can use a simple function to check a character if it has graphical representation or not. The Function is called isgraph( param a), which accepts a single parameter which defines a character.

This can be implemented in cases when you want to check for the input for the first name or last name, which should not have any whitespace, or in other words should have a graphical representation.

The isgraph() function returns true if the character has graphical representation and false if character do not have graphical representation. This function is from the ctype.h file which needs to be included in the program.

Example:

    Whitespace 	    ' ', NULL do not have graphical representation.

ctype.h - isgraph() function Example in C


#include <stdio.h>
#include <ctype.h>
 
int main()
{
	// Defining the type of variables and initializing them
	char a='A';
 
	// initializing the value of b=0
	char b= 0;
 
	// condition to prove that the value a is character
	if(isgraph(a)== 1)
	{
		printf("%c is a character \n\n", a);
	}
 
	// condition to prove that the value b is NULL
	if(isgraph(b)== 0)
	{
		printf("NULL is not a character \n");
	}
 
	return 0;
}
 

Output

ctype.h - isgraph()  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.