isgraph in c

What is isgraph in c programming?

isgraph in c is used to find whether the passed character is graphic character or not.

Whitespace character is not a graphical character.

This function is defined in ctype.h header file.

This function returns non-zero digit if passed character is graphical character otherwise zero.

Prototype

int isgraph(int c);

Parameter

This function takes integer as input parameter.

Return value

This function returns non-zero value if passed character is graphical character otherwise zero.


Example program for isgraph function in c

#include<stdio.h>
#include<ctype.h>
int main()
{
  int val='a';
  if(isgraph(val))
    printf("Passed character is graphical character \n");
  else
    printf("Passed character is not a graphical character \n");
  return 0;
}
Example program for isgraph in c programming

Code explanantion

The given input data is a graphic character or not is determined by passing it to the isgraph function. The result is printed onto the console.

isgraph() Man page


Difference between isgraph and isalpha in c

isgraph is used to find whether the passed character is graphical representable or not. isalpha function checks the passed character is alphabetic or not.

isgraph function takes integer value also as a graphical character. isalpha does not consider digit as an alphabetic character.

Prototypes are as follows

int isgraph(int c);

int isalpha(int c);
isgraphisalpha
Used to find whether the passed character is graphical representable or not.Checks the passed character is alphabetic or not.
int isgraph(int c);int isalpha(int c);

People also ask for

What is isgraph in c?

isgraph in c is used to find whether the passed character is graphical representable or not. It is defined in ctype.h header file.

What is the difference between isgraph and isdigit in c?

isgraph is used to find whether the passed character is graphical representable or not. isdigit function checks whether the passed character is a digit or not.