Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4019632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:07:42+00:00 2026-05-20T10:07:42+00:00

Does anyone know how the isgraph() function works in C? I understand its use

  • 0

Does anyone know how the isgraph() function works in C? I understand its use and results, but the code behind it is what I’m interested in.

For example, does it look at only the char value of it and compare it to the ASCII table? Or does it actually check to see if it can be displayed? If so, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:07:43+00:00Added an answer on May 20, 2026 at 10:07 am

    The code behind the isgraph() function varies by platform (or, more precisely, by implementation). One common technique is to use an initialized array of bit-fields, one per character in the (single-byte) codeset plus EOF (which has to be accepted by the functions), and then selecting the relevant bit. This allows for a simple implementation as a macro which is safe (only evaluates its argument once) and as a simple (possibly inline) function.

    #define isgraph(x) (__charmap[(x)+1]&__PRINT)
    

    where __charmap and __PRINT are names reserved for the implementation. The +1 part deals with the common situation where EOF is -1.


    According to the C standard (ISO/IEC 9899:1999):

    §7.4.1.6 The isgraph function

    Synopsis

    #include <ctype.h>
    int isgraph(int c);
    

    Description

    The isgraph function tests for any printing character except space (‘ ‘).

    And:

    §7.4 Character handling <ctype.h>

    ¶1 The header declares several functions useful for classifying and mapping
    characters.166) In all cases the argument is an int, the value of which shall be
    representable as an unsigned char or shall equal the value of the macro EOF. If the
    argument has any other value, the behavior is undefined.

    ¶2 The behavior of these functions is affected by the current locale. Those functions that
    have locale-specific aspects only when not in the “C” locale are noted below.

    ¶3 The term printing character refers to a member of a locale-specific set of characters, each
    of which occupies one printing position on a display device; the term control character
    refers to a member of a locale-specific set of characters that are not printing
    characters.167) All letters and digits are printing characters.

    166) See ‘‘future library directions’’ (7.26.2).

    167) In an implementation that uses the seven-bit US ASCII character set, the printing characters are those
    whose values lie from 0x20 (space) through 0x7E (tilde); the control characters are those whose
    values lie from 0 (NUL) through 0x1F (US), and the character 0x7F (DEL).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.