isgraph

来源:互联网 发布:淘宝在哪看购物评级 编辑:程序博客网 时间:2024/06/07 06:08
头文件:#include <ctype.h>

isgraph() 用来判断一个字符是否为除空格以外的可打印字符,其原型为:
int isgraph (int c);

【参数】c 为需要检测的字符。

【返回值】如果 c 所对应的 ASCII 码可打印,且为非空格字符,则返回非 0 值,否则返回 0。

注意,isgraph() 为宏定义,非真正函数。

【范例】判断str 字符串中哪些为可打印字符。
复制纯文本新窗口
  1. #include <ctype.h>
  2. main(){
  3. char str[] = "a5 @;";
  4. int i;
  5. for(i = 0; str[i] != 0; i++)
  6. if(isgraph(str[i]))
  7. printf("str[%d] is printable character:%d\n", i, str[i]);
  8. }
#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:;
0 0