isgraph Function

Test for a graphical character.

Include

<ctype.h>

Prototype

int isgraph (int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character, c, is a graphical character; otherwise, returns zero.

Remarks

A character is considered to be a graphical character if it is any printable character except a space.

Example

#include <ctype.h>
#include <stdio.h>

int main(void)
{
  int ch;

  ch = '3';
  if (isgraph(ch))
    printf("3 is a graphical character\n");
  else
    printf("3 is NOT a graphical character\n");

  ch = '#';
  if (isgraph(ch))
    printf("# is a graphical character\n");
  else
    printf("# is NOT a graphical character\n");

  ch = ' ';
  if (isgraph(ch))
    printf("a space is a graphical character\n");
  else
    printf("a space is NOT a graphical character\n");
}

Example Output

3 is a graphical character
# is a graphical character
a space is NOT a graphical character