#include <ctype.h> int isgraph(int c);
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.)
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.
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.
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.
#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."); }
isprint
, ispunct