isgraph() Function Example in C Programming

In this source code example, we will see how to use the isgraph() function in C programming with an example.

isgraph() Function Overview

The isgraph() function is a part of the <ctype.h> library in C. It checks whether a given character has a graphical representation when printed, excluding the space character (' '). 

Key Points: 

- The function is available in the <ctype.h> header. 

- It takes an int as its argument, which typically represents a character. 

- If the character has a graphical representation other than space, the function returns a non-zero value (true); otherwise, it returns 0 (false).

Source Code Example

#include <stdio.h>
#include <ctype.h>

int main() {
    char ch;

    printf("Enter a character: ");
    scanf("%c", &ch);

    if (isgraph(ch))
        printf("'%c' has a graphical representation.\n", ch);
        printf("'%c' does not have a graphical representation.\n", ch);

    return 0;


Enter a character: A
'A' has a graphical representation.


1. The necessary header files are included: stdio.h for input/output operations and ctype.h for the isgraph() function.

2. Within the main() function, a character variable ch is declared.

3. The user is prompted to enter a character.

4. The isgraph() function checks if the inputted character has a graphical representation excluding spaces.

5. Based on the result, a corresponding message is printed to the console.