Chapter Contents

Previous

Next
isgraph

isgraph



Graphic Character Test

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int isgraph(int c);


DESCRIPTION

isgraph tests an integer value c to determine whether it is a graphic character. (See IMPLEMENTATION below for a discussion of how a graphic character is defined in the 370 environment.)


RETURN VALUE

isgraph returns 0 if the character is not a graphic character, or a nonzero value if it is. If the argument is EOF , 0 is returned.


CAUTION

The effect of isgraph on a noncharacter argument other than EOF is undefined. Do not assume that isgraph returns either 0 or 1.

Note:    For some EBCDIC characters, neither iscntrl(c) , isspace(c) , nor isgraph(c) is true, even though this identity is sometimes used as a definition of isgraph . If isprint(c) is true, either isspace(c) or isgraph(c) is also true.  [cautionend]


IMPLEMENTATION

Not all characters considered printable in ASCII are considered printable in EBCDIC.

In the 5370 locale, isgraph returns a non-zero value for nonblank characters that are present on the 1403 PN print train. These characters include the digits and letters, plus these special characters:

| @ # $ % ¬ * ( ) - _ = + : ; " ' , . / ? < > &

This is the set of characters whose printability is guaranteed, regardless of device type. Note that a number of characters used by the C language, including the backslash, the exclamation point, the brackets, and the braces, are not included as graphic characters according to this definition.

In the POSIX locale, isgraph returns the results that are expected in an ASCII environment.


EXAMPLE

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

main()
{
   char *str;
   char input[20];
   size_t len;
   int gcount = 0;

   puts("Enter a string:");
   str = gets(input);

   len = strlen(str);

      /* Test whether all characters in a string are graphic. */
   while (isgraph(*str)) {
      ++gcount;
      ++str;
   }
   if (len == gcount)
      puts("The string entered is entirely graphic.");
   else
      puts("String is not entirely graphic.");
}


RELATED FUNCTIONS

isprint , ispunct


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.