C iscntrl function checks if a character is a control letter or not
Syntax
C iscntrl
function has the following syntax.
int iscntrl(int ch);
Header
C iscntrl
function is from header file ctype.h
.
Description
C iscntrl
function returns nonzero if
ch
is a control character or zero is returned.
Example
The following code uses C iscntrl
function to check if
a character is a control letter.
#include <ctype.h>
#include <stdio.h>
//from w ww .j a v a 2 s .c om
int main(void)
{
char ch;
for(;;) {
ch = getchar( );
if(ch == '.') {
break;
}
if(iscntrl(ch)){
printf("%c is a control char\n", ch);
}
}
return 0;
}
The code above generates the following result.