# iscntrl Function

Test for a control character.

Include

<ctype.h>

Prototype

int iscntrl(int c);

Argument

 c The character to test.

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

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#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