This blog is under construction

Saturday, 17 March 2012

isgraph example in C

Header file:
    ctype.h

Synopsis:
    int isgraph (int input)

Description:
    Checks whether the given input is a graphic character(glyph associated character).

Return Value:
    TRUE (non-zero value) on success
    0 on failure.


isgraph function C example


  #include<stdio.h>
  #include<ctype.h>
  int main() {
        char c;
        printf("Enter your input:");
        c = getchar();

        if (isgraph(c))
                printf("Given input is a graphical character\n");
        else
                printf("Given input is not a graphical character\n");

        printf("Return value from isgraph: %d\n", isgraph(c));
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms$ ./a.out
  Enter your input:q
  Given input is a graphical character
  Return value from isgraph: 32768

  /* give space as input */
  jp@jp-VirtualBox:~/cpgms$ ./a.out
  Enter your input:
  Given input is not a graphical character
  Return value from isgraph: 0

No comments:

Post a Comment