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