This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

isprint

Prototype

#include <ctype.h>

int isprint(int c);

Description

Returns a true value if the c character is a printing character including the space character (' ').

Example

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

/*
 * Print the argument character if it is a printable character,
 * otherwise its escape representation.
 */
void prchar(int c)
{
    if (isprint(c))
	putchar(c);
    else
	switch(c) {
	case '\a': putchar('\\'); putchar('a'); break;
	case '\b': putchar('\\'); putchar('b'); break;
	case '\f': putchar('\\'); putchar('f'); break;
	case '\n': putchar('\\'); putchar('n'); break;
	case '\r': putchar('\\'); putchar('r'); break;
	case '\t': putchar('\\'); putchar('t'); break;
	case '\v': putchar('\\'); putchar('v'); break;
	default:
	    printf("\\%o", c & 255);
	}
}

References

ISO C 9899:1990 7.3.1.7