This blog is under construction

Saturday, 17 March 2012

isprint example in C

Header file:
    ctype.h

Synopsis:
    int isprint (int input);

Description:
    Checks whether the given input is a printing character or not.

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


isprint function C example:


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

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

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



  Output:
  jp@jp-VirtualBox:~/cpgms$ ./a.out
  Enter your input:a
  Given input is a printing character
  Return value from isprint: 16384

  /*give '\n' - carriage return as input */
  jp@jp-VirtualBox:~/cpgms$ ./a.out
  Enter your input:
  Given input is not a printing character
  Return value from isprint: 0


No comments:

Post a Comment