Chapter Contents

Previous

Next
iscntrl

iscntrl



Control Character Test

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
CAUTION
PORTABILITY
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int iscntrl(int c);


DESCRIPTION

iscntrl tests an integer value c to determine whether it is a control character.


RETURN VALUE

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


CAUTION

The effect of iscntrl on a noncharacter argument other than EOF is undefined. Do not assume that iscntrl 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]


PORTABILITY

You should carefully examine the iscntrl function when using it in a program that is expected to be portable. IBM uses the words control character to designate characters between 0x00 and 0x3f , as well as 0xff . This implementation defines iscntrl('\xff') as false.


IMPLEMENTATION

iscntrl is implemented by a macro. iscntrl tests a character to see whether it is less than a blank in the EBCDIC collating sequence. This is true for the EBCDIC equivalents of all ASCII control characters.


EXAMPLE

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

main()
{
   char *buf;

   buf = "Hello World. \n This is a test. ";

   do {
   if (!iscntrl(*buf))
      putchar(*buf);
   else
      putchar('*');
   buf++;
   } while (*buf);
   putchar("\n");
}


RELATED FUNCTIONS

isspace


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

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