Chapter Contents

Previous

Next
ispunct

ispunct



Punctuation Test

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int ispunct(int c);


DESCRIPTION

ispunct tests an integer value c to determine whether it is punctuation. (See IMPLEMENTATION below for a discussion of the definition of this concept in the 370 environment.)


RETURN VALUE

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


CAUTION

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

Note:    For some EBCDIC characters, the return value of iscntrl(c) , isspace(c) , isalnum(c) , or ispunct(c) is not true, even though this identity is sometimes used as a definition of ispunct . If isprint(c) is true, either isspace(c) , isalnum(c) , or ispunct(c) is also true.  [cautionend]


IMPLEMENTATION

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

In the 5370 locale, ispunct returns nonzero for nonblank characters other than the digits and letters that are present on the 1403 PN print train; that is, ispunct returns nonzero for 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 punctuation according to this definition.

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


EXAMPLE

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

main()
{
   char *str, *string;
   char input[40];

   puts("Enter a string of characters (40 at most), "
        "(preferably, punctuation characters):");
   string = gets(input);

      /* Test whether all characters in string */
      /* are punctuation characters.           */
   str = string;

   do {
      if (ispunct(*str))
         putchar(*str);
      else
         putchar('X');
      ++str;
   } while(*str);
   puts("\n All characters that are not punctuation characters "
        "have been replaced by 'X'.");
}


RELATED FUNCTIONS

isgraph , isprint


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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