Check if character is printable
Checks whether c is a printable character.
A printable character is a character that occupies a printing position on a display (this is the opposite of a control character, checked with iscntrl).
For the standard ASCII character set (used by the "C" locale), printing characters are all with an ASCII code greater than 0x1f (US), except 0x7f (DEL).
isgraph returns true for the same cases as isprint except for the space character (' '), which returns true when checked with isprint but false when checked with isgraph.
For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the <cctype> header.
In C++, a locale-specific template version of this function (isprint) exists in header <locale>.
- Character to be checked, casted to an int, or EOF.
A value different from zero (i.e., true) if indeed c is a printable character. Zero (i.e., false) otherwise.
/* isprint example */
int main ()
char str="first line \n second line \n";
This code prints a string character by character until a character that is not printable is checked and breaks the while-loop. In this case, only the first line would be printed, since the line ends with a newline character ('\n'), which is not a printable character.
- Check if character is a control character (function)
- Check if character is a white-space (function)
- Check if character is alphanumeric (function)