C library function - isprint()
Description
C Library Function int isprint(int c) Checks whether the passed character is printable. A printable character is one that is not a control character.
Declaration
Here is the declaration of the isprint() function.
int isprint(int c);
Parameters
- c -- This is the character to be checked.
Return Value
If c is a printable character, the function returns a nonzero value (true); otherwise it returns 0 (false).
Example
The following example demonstrates the use of the isprint() function.
#include
#include
int main()
{
int var1 = 'k';
int var2 = '8';
int var3 = '\t';
int var4 = ' ';
if( isprint(var1) )
{
printf("var1 = |%c| 是可打印的\n", var1 );
}
else
{
printf("var1 = |%c| 是不可打印的\n", var1 );
}
if( isprint(var2) )
{
printf("var2 = |%c| 是可打印的\n", var2 );
}
else
{
printf("var2 = |%c| 是不可打印的\n", var2 );
}
if( isprint(var3) )
{
printf("var3 = |%c| 是可打印的\n", var3 );
}
else
{
printf("var3 = |%c| 是不可打印的\n", var3 );
}
if( isprint(var4) )
{
printf("var4 = |%c| 是可打印的\n", var4 );
}
else
{
printf("var4 = |%c| 是不可打印的\n", var4 );
}
return(0);
}
Let's compile and run the above program, which will produce the following result:
var1 = |k| 是可打印的
var2 = |8| 是可打印的
var3 = | | 是不可打印的
var4 = | | 是可打印的
C Standard Library -