Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
ciso646 (iso646.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cctype (ctype.h)
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
tolower
toupper


isgraph

function
<cctype>
int isgraph ( int c );

Check if character has graphical representation

Checks if parameter c is a character with graphical representation. The characters with graphical representation are all those characters than can be printed (as determined by isprint) except for whitespace characters (like ' '), which are not considered isgraph characters.

For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the <cctype> header.

In C++, a locale-specific template version of this function (isgraph) exists in header <locale>.

Parameters

c
Character to be checked, casted to an int, or EOF.

Return Value

A value different from zero (i.e., true) if indeed c has a graphical representation as character. Zero (i.e., false) otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* isgraph example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  FILE * pFile;
  int c;
  pFile=fopen ("myfile.txt","r");
  if (pFile)
  {
    do {
      c = fgetc (pFile);
      if (isgraph(c)) putchar (c);
    } while (c != EOF);
    fclose (pFile);
  }
 }


This example prints out the contents of "myfile.txt" without spaces and special characters, i.e. only prints out the characters that qualify as isgraph.

See also