ADVERTISEMENT
ADVERTISEMENT

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

ADVERTISEMENT


#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

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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 some rights reserved.