#include <ctype.h> int isprint(int c);
isprint
tests an integer value c
to determine whether it is a
printing character. (See IMPLEMENTATION below for a discussion of the
definition of this concept in the 370 environment.)
isprint
returns 0 if the character is not a printing character, or a
nonzero value if it is. If the argument is EOF
, 0 is
returned.
isprint
on a noncharacter argument other than EOF
is undefined. Do not assume that isprint
returns either 0 or 1.
Note:
For some EBCDIC characters, neither iscntrl(c)
nor
isprint(c)
is true, even though this identity is sometimes used as a
definition of isprint
.
In the 5370 locale, isprint
returns a nonzero value for characters
that are present on the 1403 PN print train. These characters include the digits and
letters, the blank, and 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 printing characters according to this definition.
In the POSIX locale, isprint
returns the results that are
expected in an ASCII environment.
#include <ctype.h> #include <stdio.h> main() { char *str, *string; char input[20]; puts("Enter a string (max: 20 characters)."); puts("Note: Do not enter the character '*':"); string = gets(input); /* Test whether all characters in a word are printable. */ str = string; do { if (isprint(*str)) putchar(*str); else putchar('*'); ++str; } while(*str); puts("/nAll unprintable characters have been replaced by '*'."); }
isgraph
, ispunct
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.