[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
isprint()                Test for Printable Character

 #include   <ctype.h>

 int        isprint(c);
 int        c;                           Integer value to be tested


    isprint() tests if 'c' is a printable character.  Printable
    characters have an ASCII value between 32 - 126, (0x20 - 0x7e), a
    space and the tilde, inclusive.

    Returns:    True (nonzero) if the integer satisfies the test
                condition or false (zero) if it does not.  The result is
                undefined if 'c' is other than an ASCII character or EOF.

      Notes:    isprint() is a macro.

  -------------------------------- Example ---------------------------------

    The following statements read characters from one file and, if
    printable, write them out to a second file.

         #include <ctype.h>
         #include <stdio.h>             /* for fopen */

         FILE *in, *out;
         int ch;

         main()
         {
             if ((in = fopen("good.dat","w+")) != NULL &&
                  (out =  fopen("input.dat", "r+")) != NULL) {
                       while (!feof(in))
                           if (isprint(ch = getc(in)))
                               putc(ch,out);
             }
         }

See Also: isalnum() isalpha() isascii() iscntrl() isgraph()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson