isgraph function checks whether a character is graphic character or not. The characters with graphical representation are all those characters than can be printed, except the space character(" ") which is not a graph character.
Function prototype of isgraph
Return value of isgraph
If passed character has graphical representation as character, then isgraph function returns non-zero integer otherwise 0.
C program using isgraph function
The following program is to check whether a character has graphical representation or not.
#include <stdio.h> #include <ctype.h> int main(){ char string[] = "1 A"; int index = 0; while(string[index] != '\0'){ if(isgraph(string[index])){ printf("'%c' is a graphical character\n", string[index]); } else { printf("'%c' is not a graphical character\n", string[index]); } index++; } return 0; }
Output
'1' is a graphical character ' ' is not a graphical character 'A' is a graphical character