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>isatty() check for character device</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 isatty()                Check for Character Device

 #include   <io.h>

 int        isatty(handle);
 int        handle;                      Handle of the device being tested

    isatty() checks whether 'handle' is associated with a character
    device (i.e., a terminal, console, printer, or serial port).

       Returns:     Non-zero if 'handle' is associated with a character
                    device; otherwise zero.

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

    The following statements determine if 'fhndl' is associated with a
    character device. If not, they get the file pointer position.

           #include <io.h>
           #include <stdio.h>

           int fhndl;
           long position;
           FILE *stream;

           main()
           {
               stream = fopen("book.dat","w+");
               fhndl = fileno(stream);
               if (isatty(fhndl) == 0) {
                   position = ftell(fhndl);
                   printf("file position: %ld\n",position);
               }
               else
                   printf("handle associated with device");
           }





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