
- C 標準庫
- C 庫 - 首頁
- C 庫 - <assert.h>
- C 庫 - <complex.h>
- C 庫 - <ctype.h>
- C 庫 - <errno.h>
- C 庫 - <fenv.h>
- C 庫 - <float.h>
- C 庫 - <inttypes.h>
- C 庫 - <iso646.h>
- C 庫 - <limits.h>
- C 庫 - <locale.h>
- C 庫 - <math.h>
- C 庫 - <setjmp.h>
- C 庫 - <signal.h>
- C 庫 - <stdalign.h>
- C 庫 - <stdarg.h>
- C 庫 - <stdbool.h>
- C 庫 - <stddef.h>
- C 庫 - <stdio.h>
- C 庫 - <stdlib.h>
- C 庫 - <string.h>
- C 庫 - <tgmath.h>
- C 庫 - <time.h>
- C 庫 - <wctype.h>
- C 標準庫資源
- C 庫 - 快速指南
- C 庫 - 有用資源
- C 庫 - 討論
- C 程式設計資源
- C 程式設計 - 教程
- C - 有用資源
C 庫 - isgraph() 函式
C 的ctype庫 isgraph() 函式檢查字元是否具有圖形表示。具有圖形表示的字元是所有可以列印的字元,除了空格字元(如 ' '),空格字元不被認為是 isgraph 字元。這包括所有在顯示器上產生可見標記的字元,例如字母、數字、標點符號等,但不包括空格、製表符或換行符等空格字元。
語法
以下是 isgraph() 函式的 C 庫語法:
int isgraph(int c);
引數
此函式接受單個引數:
int c : 這是要檢查的字元,作為整數傳遞。字元通常以其 ASCII 值傳遞。
返回值
如果字元是可列印字元(空格字元除外),則該函式返回非零值(true);如果字元不是可列印字元(空格字元除外),則返回 0(false)。
示例 1:檢查字母字元
字元 'A' 是字母字元,並且是可圖形列印的,因此 isgraph() 返回 true。
#include <stdio.h> #include <ctype.h> int main() { char ch = 'A'; if (isgraph(ch)) { printf("'%c' is a printable character other than space.\n", ch); } else { printf("'%c' is not a printable character or it is a space.\n", ch); } return 0; }
輸出
以上程式碼產生以下結果:
'A' is a printable character other than space.
示例 2:檢查空格字元
空格不被認為是圖形字元。因此,isgraph() 函式返回 false。
#include <stdio.h> #include <ctype.h> int main() { char ch = ' '; if (isgraph(ch)) { printf("'%c' is a printable character other than space.\n", ch); } else { printf("'%c' is not a printable character or it is a space.\n", ch); } return 0; }
輸出
執行以上程式碼後,我們得到以下結果:
' ' is not a printable character or it is a space.
廣告