C examples for ctype.h:isprint
function
<cctype> <ctype.h>
Check if character is printable
int isprint ( int c );
Parameter | Description |
---|---|
c | Character to be checked, casted to an int, or EOF. |
A non zero value (i.e., true) if indeed c is a printable character. Zero (i.e., false) otherwise.
The following code prints a string character by character until a character that is not printable.
#include <stdio.h> #include <ctype.h> int main ()//from w ww . j av a2s . c om { int i=0; char str[]="first line \n second line \n"; while (isprint(str[i])) { putchar (str[i]); i++; } return 0; }