iscntrl in c

What is iscntrl in c programming?

iscntrl in c is used to find passed character is control character or not.

This function is defined in ctype.h header file.

This function returns non-zero digit if passed character is control character otherwise zero.

Prototype

int iscntrl(int c);

Parameter

This function takes character as input parameter and converts it into ASCII value.

Return value

This function returns non-zero value if passed character is control character otherwise zero.


Example program for iscntrl function in c

#include<stdio.h>
#include<ctype.h>
int main()
{
  int i=0;
  char str[]="scholarsoul \t tutorial";
  while(!iscntrl(str[i]))
  {
    putchar(str[i]);
    i++;
  }
  return 0;
}
Example program for iscntrl in c programming

Code explanation

The given character is a control character or not is determined by passing it the iscntrl function. The result is being printed onto the console.

iscntrl() Man page


Difference between iscntrl and isblank in c

iscntrl is used to find the passed character is a control character or not. isblank in c checks whether the passed character is blank or not.

iscntrl function terminates the process when it encounters a control character. isblank function is used to find blank space between the words in a line of text.

Prototypes are as follows

int iscntrl(int c);

int isblank(int a);
iscntrl function in cisblank function in c
Used to find passed character is control character or not.Checks whether the passed character is blank or not.
int iscntrl(int c);int isblank(int a);

Difference between iscntrl and isspace in c

iscntrl in c is used to find the passed character is a control character or not. isspace function checks the input character is whitespace or not.

iscntrl function terminates the process when it encounters a control character. isspace simply returns character is space or not.

Prototypes are as follows

int iscntrl(int c);

int isspace(int c);
iscntrl function in cisspace function in c
Used to find passed character is control character or not.Checks the input character is whitespace or not.
int iscntrl(int c);int isspace(int c);

People also ask for

What is iscntrl in c?

iscntrl in c is used to find the passed character is a control character or not. This function is defined in ctype.h header file.