isatty -- Test Handle for Character Device

Format

#include <io.h>
int isatty(int handle);

Language Level: XPG4, Extension
isatty determines whether the given handle is associated with a character device (a keyboard, display, or printer or serial port).

Note: In earlier releases of the C/C++ run-time library, isatty began with an underscore (_isatty). Because it is defined by the X/Open standard, the underscore has been removed. For compatibility, IBM C and C++ Compilers will map _isatty to isatty for you.

Return Value
isatty returns a nonzero value if the device is a character device. Otherwise, the return value is 0.

Example
This example opens the console and determines if it is a character device:

#include <io.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
   int fh;
   if (-1 == (fh = fileno(stdin))) {
      perror("Error getting file handle from stdin.\n");
      return EXIT_FAILURE;
   }
   if (0 != isatty(fh))
      printf("stdin is a character device.\n");
   else
      printf("stdin is not a character device.\n");
   return 0;
   /***************************************************
      The output should be:
      stdin is a character device.
   ***************************************************/
}


_inp -- Read Byte from Input Port
_inpd -- Read Doubleword from Input Port
_inpw -- Read Unsigned Short from Input Port
_outp -- Write Byte to Output Port
_outpd -- Write Double Word to Output Port
_outpw -- Write Word to Output Port
<io.h>