函式
<cctype>

isgraph

int isgraph ( int c );
檢查字元是否有圖形表示
檢查 c 是否是具有圖形表示的字元。

具有圖形表示的字元是所有可以列印的字元(由 isprint 決定),但不包括空格字元(' ').

有關不同ctype函式為標準 ASCII 字元集中的每個字元返回值的詳細圖表,請參閱 <cctype> 標頭檔案的參考。

在 C++ 中,此函式的一個針對本地環境的模板版本 (isgraph) 存在於標頭檔案 <locale> 中。

引數

c
要檢查的字元,需轉換為int型別,或為EOF.

返回值

如果 c 確實具有圖形表示,則返回一個非零值(即true)。否則,返回零(即false)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* isgraph example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  FILE * pFile;
  int c;
  pFile=fopen ("myfile.txt","r");
  if (pFile)
  {
    do {
      c = fgetc (pFile);
      if (isgraph(c)) putchar (c);
    } while (c != EOF);
    fclose (pFile);
  }
}

此示例打印出"myfile.txt"的內容,但不包括空格和特殊字元,即僅打印出符合isgraph.

另見