cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : C Library : cctype (ctype.h) : isgraph
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
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)
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
int isgraph ( int c );
<cctype>

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.

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

/* 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

isprint Check if character is printable (function)
isspace Check if character is a white-space (function)
isalnum Check if character is alphanumeric (function)

Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us