Menu
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

C ctype iscntrl() Function

❮ C ctype Library


Example

Check if a character is a control character:

char c = '\n';
if (iscntrl(c)) {
  printf("'%c' (ASCII value %d) is a control character", c, c);
} else {
  printf("'%c' (ASCII value %d) is not a control character", c, c);
}
Try it Yourself »

Definition and Usage

The iscntrl() function returns a non-zero value (equivalent to boolean true) if a character is a control character. Control characters are characters that provide instructions to text processors and other programs.

Examples of common control characters are: \n (newline), \t (tab), \b (backspace), etc.

The characters with an ASCII value less than 32 or equal to 127 are control characters.

The iscntrl() function is defined in the <ctype.h> header file.


Syntax

int iscntrl(int c);

Parameter Values

Parameter Description
c Required. The ASCII value of a character or an actual character

Technical Details

Returns: An int value which is non-zero (equivalent to boolean true) if the character is a control character.

Otherwise it returns 0 (equivalent to boolean false).

❮ C ctype Library