isgraph function(Test for Graphical Character) in C Language – example and detail

In the C Programming Language, the isgraph characteristic exams whether c is a printing character, but does not consist of a space. If you want to encompass a space, strive using the isprint function.

Syntax

The syntax for the isgraph feature in the C Language is:

int isgraph(int c);

Parameters or Arguments

c The price to test whether it is a printing character, but does no longer consist of a space.

Returns

The isgraph feature returns a nonzero price if c is a printing character and returns zero if c is now not a printing character.

Required Header

In the C Language, the required header for the isgraph function is:

#include <ctype.h>

Applies To

In the C Language, the isgraph feature can be used in the following versions:

ANSI/ISO 9899-1990

isgraph Example

/* Example using isgraph by TechOnTheNet.com */

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

int main(int argc, const char * argv[])
{
    /* Define a temporary variable */
    unsigned char test;

    /* Assign a test printable letter to the variable */
    test = 'T';

    /* Test to see if this character is a printing character */
    if (isgraph(test) != 0) printf("%c is a printing character\n", test);
    else printf("%c is not a printing character\n", test);

    /* Assign a non-printing character to the variable */
    test = 0; /* This is NUL */

    /* Test to see if this character is a printing character */
    if (isgraph(test) != 0) printf("NUL is a printing character\n");
    else printf("NUL is not a printing character\n");

    return 0;
}

When compiled and run, this utility will output:

T is a printing character
NUL is not a printing character

Similar Functions

Other C functions that are comparable to the isgraph function:

iscntrl function isprint function isspace characteristic