C language Isprint () function: To determine whether a character is a printable character
header file:
The Isprint () function is used to determine whether a character is a printed character, and its prototype is:
"Parameter" C is the character that needs to be detected.
' Return value ' If C is a printable character, returns a value other than 0, otherwise returns 0.
The ASCII value of printable characters is greater than 0x1f (except for 0x7f (DEL), these characters can be displayed on the screen, let us see, can not be displayed on the screen, we do not see, called control characters, ASCII code value of 0x00 ~ 0x1f, plus 0x7f (del). To detect control characters, use the Isiscntrl () function.
Note that this function is defined for a macro and is not a true function.
"Instance" determines which printable characters in the STR string contain space characters.
#include <ctype.h>
Main () {
char str[] = "A5 @;";
int i;
for (i = 0; Str[i]!= 0. i++)
if (Isprint (str[i)))
printf ("str[%d" is printable character:%d\n ", I, Str[i]);
}
Output results:
Str[0] is printable character:a
str[1] are printable Character:5
str[2] is printable character:
str[3] is Prin Table character:@
str[4] is printable character:;
C language Isgraph () function: To determine whether a character is a printable character other than a space
header file:
Isgraph () is used to determine whether a character is a printable character other than a space, and its prototype is:
"Parameter" C is the character you want to detect.
Return value if C's ASCII code is printable and is not a space character, returns a value other than 0, or 0.
Note that isgraph () is a macro definition, not a true function.
"Example" determines which of the STR strings are printable characters.
#include <ctype.h>
Main () {
char str[] = "A5 @;";
int i;
for (i = 0; Str[i]!= 0. i++)
if (Isgraph (str[i)))
printf ("str[%d" is printable character:%d\n ", I, Str[i]);
}
Output results:
Str[0] is printable character:a
str[1] are printable Character:5
str[3] is printable character:@ str[4
] is PRI ntable character:;