_isatty

Description

Checks for a character device.

#include <io.h> Required only for function declarations  

int _isatty( int handle );

handle Handle referring to device to be tested  

Remarks

The _isatty function determines whether handle is associated with a character device (a terminal, console, printer, or serial port).

Return Value

The _isatty function returns a nonzero value if the device is a character device. Otherwise, the return value is 0.

Compatibility

Standards:UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

Use _isatty for compatibility with ANSI naming conventions of non-ANSI functions. Use isatty and link with OLDNAMES.LIB for UNIX compatibility.

Example

/* ISATTY.C: This program checks to see whether stdout has been

* redirected to a file.

*/

#include <stdio.h>

#include <io.h>

void main( void )

{

if( _isatty( _fileno( stdout ) ) )

printf( "stdout has not been redirected to a file\n" );

else

printf( "stdout has been redirected to a file\n");

}

Output

stdout has not been redirected to a file