Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>isprint() test for printable character (macro)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 isprint()               Test for Printable Character (Macro)

 #include   <ctype.h>

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

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

       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()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson