C庫函數isgraph()檢查字符是否為圖形字符。已知具有圖形表示的字符為圖形字符。例如:‘:’‘;’‘?’‘@’等。
句法 -
#include <ctype.h> int isgraph(int ch);
返回值 -如果 ch 是空格以外的任何可打印字符,則函數返回非零值,否則返回 0。
對於 ASCII 環境,可打印字符在 0X21 到 0X7E 的範圍內。
代碼 -
// code to check graphical character
#include <stdio.h>
#include <ctype.h>
int main()
{
char var1 = 'g';
char var2 = ' ';
char var3 = '1';
if (isgraph(var1))
printf("var1 = |%c| can be printed\n", var1);
else
printf("var1 = |%c| can't be printed\n", var1);
if (isgraph(var2))
printf("var2 = |%c| can be printed\n", var2);
else
printf("var2 = |%c| can't be printed\n", var2);
if (isgraph(var3))
printf("var3 = |%c| can be printed\n", var3);
else
printf("var3 = |%c| can't be printed\n", var3);
return (0);
}
輸出-
var1 = |g| can be printed var2 = | | can't be printed var3 = |1| can be printed
代碼 -
// code to print all Graphical Characters
#include <stdio.h>
#include <ctype.h>
int main()
{
int i;
printf("In C programming All graphic "
"characters are:\n");
for (i = 0; i <= 127; ++i)
if (isgraph(i) != 0)
printf("%c ", i);
return 0;
}
輸出-
In C programming All graphic characters are: ! " # $ % & ' ( ) * +, - . / 0 1 2 3 4 5 6 7 8 9 :; ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
相關用法
注:本文由純淨天空篩選整理自GeeksforGeeks大神的英文原創作品 isgraph() C library function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。