For the standard ASCII character set, control characters are those between ASCII codes 0x00 (NUL) and 0x1f (US), plus 0x7f (DEL). Therefore, printable characters are all but these, although specific compiler implementations for certain platforms may define additional control characters in the extended character set (above 0x7f).
isgraph returns true for the same cases as isprint except for the whitespace characters (like ' '), which return 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.
Return ValueA value different from zero (i.e., true) if indeed c is a printable character. Zero (i.e., false) otherwise.
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.
|iscntrl||Check if character is a control character (function)|
|isspace||Check if character is a white-space (function)|
|isalnum||Check if character is alphanumeric (function)|