Name
isprint
Synopsis
Ascertains whether a given character is printable
#include <ctype.h> intisprint( intc);
The isprint() function
tests whether its argument is a printing character. If the argument
is a printing character, isprint() returns a nonzero value (that
is, true); if not, the function
returns 0 (false).
“Printing” means only that the character occupies printing
space on the output medium, not that it fills the space with a
glyph. Thus the space is a printing character (isprint(' ') returns true), even though it does not leave a
mark (isgraph(' ') returns
false).
Which character codes represent printable characters depends
on the current locale setting for the category LC_CTYPE, which you can query or change
using the setlocale() function.
In the default locale C, the
printable characters are the alphanumeric characters, the
punctuation characters, and the space character; the corresponding
character codes are those from 32
through 126.
Example
unsigned int c; printf("\nThe current locale for the 'is ...' functions is '%s'.\n", setlocale(LC_CTYPE, NULL)); printf("Here is a table of the 'is ...' values for the characters" " from 0 to 127 in this locale:\n\n"); for ( c = 0; c < 128; c++ ) // Loop iteration for each table row. { if ( c % 24 == 0 ) // Repeat table header every 24 rows. { printf("Code char alnum alpha blank cntrl digit graph lower" " print punct space upper xdigit\n"); printf("---------------------------------------------------" "-------------------------------\n"); ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access