iscntrl function(Test for Control Character) in C Language – example and detail

In the C Programming Language, the iscntrl feature exams whether or not c is a manipulate character.


The syntax for the iscntrl feature in the C Language is:

int iscntrl(int c);

Parameters or Arguments

c The fee to test whether it is a control character.


The iscntrl characteristic returns a nonzero fee if c is a manipulate persona and returns zero if c is now not a control character.

Required Header

In the C Language, the required header for the iscntrl function is:

#include <ctype.h>

Applies To

In the C Language, the iscntrl function can be used in the following versions:

ANSI/ISO 9899-1990

iscntrl Example

/* Example using iscntrl by */

#include <stdio.h>
#include <ctype.h>

int main(int argc, const char * argv[])
    /* Define a temporary variable */
    unsigned char test;

    /* Assign a test control character to the variable */
    test = 0; /* This is NUL */

    /* Test to see if this is a control character */
    if (iscntrl(test) != 0) printf("NUL is a control character\n");
    else printf("NUL is not a control character\n");

    /* Assign a non-control character to the variable */
    test = 'T';

    /* Test to see if this is a control character */
    if (iscntrl(test) != 0) printf("%c is a control character\n", test);
    else printf("%c is not a control character\n", test);

    return 0;

When compiled and run, this utility will output:

NUL is a control character
T is not a control character

Similar Functions

Other C features that are similar to the iscntrl function:

isgraph function isprint function isspace feature