Syntax
#include <io.h> int isatty(int handle);Description
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 C Set ++, isatty began with an underscore (_isatty). Because it is defined by the X/Open standard, the underscore has been removed. For compatibility, The Developer's Toolkit will map _isatty to isatty for you.
isatty returns a nonzero value if the device is a character device. Otherwise, the return value is 0.
This example opens the console and determines if it is a character device:
#include <io.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <sys\stat.h> int main(void) { int fh,result; if (-1 == (fh = open("CON", O_RDWR, (S_IREAD|S_IWRITE)))) { perror("Error opening console\n"); return EXIT_FAILURE; } result = isatty(fh); if (0 != result) printf("CON is a character device.\n"); else printf("CON is not a character device.\n"); close(fh); return 0; /**************************************************************************** The output should be: CON is a character device. ****************************************************************************/ }Related Information
none