c语言isgraphis()函数怎么判断字符是否为可打印字符



c语言isgraphis()函数怎么判断字符是否为可打印字符?isgraphis()函数使用实例教程。需要引入的头文件:#include <ctype.h>

isgraphis()函数的定义:int isgraph (int c);

isgraphis()函数使用介绍:检查参数 c 是否为可打印字符,若c 所对应的ASCII 码可打印,且非空格字符则返回true。

isgraphis()函数返回值:若参数c 为可打印字符,则返回true,否则返回null(0)。

使用说明:此为宏定义,非真正函数。

isgraphis()函数返回值:判断str 字符串中哪些为可打印字符。
#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]);
}

实例代码执行结果:
str[0] is printable character:a
str[1] is printable character:5
str[3] is printable character:@
str[4] is printable character:;