C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs



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







You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.


Comments and Discussions