C – iscntrl() function

      Prev                                                                                              Next

  • 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 ‘’ ( 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:

#include <stdio.h>

int main()
{
   char ch[5] ="abca";
   int i = 0;
while(1)
   {
      if(iscntrl(ch[i]))
      {
          printf ( "control character is found at " 
                    "%dth positionn", i+1); 
         break;
      }
      i++;
   }   
   return 0;
}

Output:

control character is found at 4th position

Other Int, Char validation functions in C language:

  • All “int, char validation functions” used in C language are given below. “ctype.h” header files support all these functions in C language.
  • Click on each function name below for detail description and example programs.
S.no Function Description
1 isalpha() checks whether character is alphabetic
2 isdigit() checks whether character is digit
3 isalnum() checks whether character is alphanumeric
4 isspace() checks whether character is space
5 islower() checks whether character is lower case
6 isupper() checks whether character is upper case
7 isxdigit() checks whether character is hexadecimal
8 iscntrl() checks whether character is a control character
9 isprint() checks whether character is a printable character
10 ispunct() checks whether character is a punctuation
11 isgraph() checks whether character is a graphical character
12 tolower() checks whether character is alphabetic & converts to lower case
13 toupper() checks whether character is alphabetic & converts to upper case

      Prev                                                                                              Next

.