Chapter Contents

Previous

Next
isprint

isprint



Printing 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 isprint(int c);


DESCRIPTION

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.)


RETURN VALUE

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.


CAUTION

The effect of 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 .  [cautionend]


IMPLEMENTATION

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

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.


EXAMPLE

#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 '*'.");
}


RELATED FUNCTIONS

isgraph , ispunct


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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