iscntrl() - Character Function

How is "iscntrl()" used in C++?

Explanation

iscntrl() is used to check if the given argument contains control characters or symbols like null (), bell (a), backspace (b), horizontal tab (\t), line feed00 (\n), form feed (f), carriage return (r), escape (e) and delete. This function returns zero when the argument is not having any of the symbols.

Syntax:


int iscntrl ( int c );

Example :



#include <stdio.h>
#include <cctype.h>
int main()
{
char a = '\t';
if ( iscntrl(a))
{
printf ( "Tab space is a Control character");
}
else
{
printf("Tab space is not a Control character");
}
return 0;
}

Result :

Tab space is a Control character

In the above example, this function is used to check if the tab space is a control character. The symbols check is made using the cctype facet.

C++ Tutorial


Ask Questions

Ask Question