Test for a control character.
Include
<ctype.h>
Prototype
int iscntrl(int c);
Argument
c
Return Value
Returns a non-zero integer value if the character, c
, is a
control character; otherwise, returns zero.
Remarks
A character is considered to be a control character if its ASCII value is in the range 0x00 to 0x1F inclusive, or 0x7F.
Example
#include <ctype.h>
#include <stdio.h>
int main(void)
{
char ch;
ch = 'B';
if (iscntrl(ch))
printf("B is a control character\n");
else
printf("B is NOT a control character\n");
ch = '\t';
if (iscntrl(ch))
printf("A tab is a control character\n");
else
printf("A tab is NOT a control character\n");
}
Example Output
B is NOT a control character
a tab is a control character