isgraph() - Character Function

How is "isgraph()" used in C++?

Explanation

isgraph() is used to check if the argument is a graphical representation or character that can be printed except whitespace characters. If graphical representation are not found, the function returns zero.

Syntax:


int isgraph ( int c );

Example :



#include <stdio.h>
#include <ctype.h>
int main()
{
if( isgraph( ' ' ) )
{
printf( "Space is a graphic character\n" );
}
else
{
printf("Space is not a graphic character\n");
}
if( isgraph( 'C' ) )
{
printf( "Character C is graph\n" );
}
return 0;
}

Result :

Space is not a graphic character
Character C is graph

In the above example, this function is used to check space and "A". The Checking of the graphical representation has been made based on ASCII values.

C++ Tutorial


Ask Questions

Ask Question