Prev Next
iscntrl() function in C:
- iscntrl( ) function in C language checks whether given character is control character or not. Syntax for iscntrl( ) function is given below.
int iscntrl( int x );
- Control characters in C language are ‘\a’ ( alert ), ‘\b’ ( backspace ), ‘\f’ ( form feed ), ‘\n’ ( new line ), ‘\r’ ( carriage return ), ‘\t’ ( horizondal tab), ‘\v’ ( vertical tab) and ‘\0’ ( null ).
Note:
- ‘\a’ – Alert character is used to produce visible or audible alert in output.
- ‘\b’ -It is used to move the position of pointer to one position back in current line.
- ‘\f’ – form feed character is used to start a new page.
- ‘\n’- new line character moves to the next line from the current line.
- ‘\r’ – carriage return is used to move the position to the beginning of current line.
- ‘\t’ – It is used to move the pointer to the horizontal tab space in current line.
Example program for iscntrl() function in C:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <stdio.h> int main() { char ch[5] ="abc\a"; int i = 0; while(1) { if(iscntrl(ch[i])) { printf ( "control character is found at " \ "%dth position\n", i+1); break; } i++; } return 0; } |
Output:
control character is found at 4th position |
Other Int, Char validation functions in C programming language:
- All “int, char validation functions” used in C programming language are given below. “ctype.h” header file support all these functions in C language.
- Click on each function name below for detail description and example programs.
Functions | Description |
isalpha() | checks whether character is alphabetic |
isdigit() | checks whether character is digit |
isalnum() | Checks whether character is alphanumeric |
isspace() | Checks whether character is space |
islower() | Checks whether character is lower case |
isupper() | Checks whether character is upper case |
isxdigit() | Checks whether character is hexadecimal |
iscntrl() | Checks whether character is a control character |
isprint() | Checks whether character is a printable character |
ispunct() | Checks whether character is a punctuation |
isgraph() | Checks whether character is a graphical character |
tolower() | Checks whether character is alphabetic & converts to lower case |
toupper() | Checks whether character is alphabetic & converts to upper case |