C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programs » ctype.h header file functions

iscntrl() function of ctype.h in C

In this article, we are going to learn about the iscntrl() function of ctype.h header file in C programming language and use it to identify the control characters.
Submitted by Abhishek Sharma, on April 10, 2018

This function takes a parameter of a character and checks if the character is controlled or not. The function returns zero if the character is not controlled and ‘one’ if the character is not controlled.

Using this function is rather simple because all it takes is a character of type char and returns an integer. The Value of integer determines if the character is controlled or not.

This function can be used to identify the null characters in the array of characters or user’s input at a certain point.


    Input character is: ‘a’
    Function will return 1

    Input character is: ‘DEL’
    Function will return 0

ctype.h - iscntrl() function Example in C

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

int main()
	// defining the type of variable
	char a;
	int b;

	// assigning the value of variable
	a = 'A';
	b = 0;

	// condition to test the control characters

	if (iscntrl(a) != 0)
		printf("%c is a control character\n", a);
		printf("%c is not a control character\n", a);

	if (iscntrl(b) != 0)
		printf("NULL is a control character\n");
		printf("NULL is not a control character\n");

	return 0;


ctype.h - isctrl()  in c language

You may also be interested in...

C/C++ Tips and Tricks...

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions