ฟังก์ชัน isgraph() ใช้เพื่อตรวจสอบว่าอักขระที่ส่งผ่านมีการแสดงแบบกราฟิกหรือไม่ มันถูกประกาศในไฟล์ส่วนหัว “ctype.h”
นี่คือไวยากรณ์ของ isgraph() ในภาษา C
int isgraph(int char);
นี่คือตัวอย่าง isgraph() ในภาษา C
ตัวอย่าง
#include<stdio.h>
#include<ctype.h>
int main() {
int a = '\n';
int b = '8';
int c = 's';
if(isgraph(a))
printf("The character has graphical representation\n");
else
printf("The character isn’t having graphical representation\n");
if(isgraph(b))
printf("The character has graphical representation\n");
else
printf("The character isn’t having graphical representation");
if(isgraph(c))
printf("The character has graphical representation\n");
else
printf("The character isn’t having graphical representation");
return 0;
} ผลลัพธ์
The character isn’t having graphical representation The character has graphical representation The character has graphical representation
ในโปรแกรมข้างต้น มีการประกาศและเริ่มต้นตัวแปรสามตัว ตัวแปรเหล่านี้ถูกตรวจสอบว่ามีการแสดงแบบกราฟิกหรือไม่ใช้ฟังก์ชัน isgraph()
if(isgraph(a))
printf("The character has graphical representation\n");
else
printf("The character isn’t having graphical representation\n");