C Library Function - iscntrl()
Description
C Library Function void iscntrl(int c) Check whether the passed character is a control character.
According to the standard ASCII character set, control characters have ASCII codes between 0x00 (NUL) and 0x1f (US), as well as 0x7f (DEL); some platform-specific compiler implementations may also define additional control characters in the extended character set (above 0x7f).
Declaration
Below is the declaration of the iscntrl() function.
int iscntrl(int c);
Parameters
- c -- This is the character to be checked.
Return Value
If c is a control character, the function returns a nonzero value; otherwise, it returns 0.
Example
The following example demonstrates the use of the iscntrl() function.
#include
#include
int main ()
{
int i = 0, j = 0;
char str1[] = "all \a about \t programming";
char str2[] = "Runoob \n tutorials";
/* Output string until control character \a */
while( !iscntrl(str1[i]) )
{
putchar(str1[i]);
i++;
}
/* Output string until control character \n */
while( !iscntrl(str2[j]) )
{
putchar(str2[j]);
j++;
}
return(0);
}
Let's compile and run the above program, which will produce the following result:
all Runoob
C Standard Library -