C Library Functions -iscntrl()
C Standard Library - <ctype.h>
Description
C Library Functionsvoid iscntrl(int c)Checks whether the passed character is a control character.
According to the standard ASCII character set, control characters have ASCII encodings between 0x00 (NUL) and 0x1f (US), as well as 0x7f (DEL). On certain platforms, 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);
Parameter
- 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 usage of the iscntrl() function.
#include <stdio.h>
#include <ctype.h>
int main ()
{
int i = 0, j = 0;
char str1[] = "all \a about \t programming";
char str2[] = "Example \n tutorials";
/* 输出字符串直到控制字符 \a */
while( !iscntrl(str1[i]) )
{
putchar(str1[i]);
i++;
}
/* 输出字符串直到控制字符 \n */
while( !iscntrl(str2[j]) )
{
putchar(str2[j]);
j++;
}
return(0);
}
Let us compile and run the above program, which will produce the following result:
all Exampleother extensions