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

Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.