_isatty
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

_isatty

int _isatty(
   int fd 
);

Parameter

fd
File descriptor referring to device to be tested.

Return Value

_isatty returns a nonzero value if the descriptor is associated with a character device. Otherwise, _isatty returns 0.

Remarks

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

Requirements

Routine Required header Compatibility
_isatty <io.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

// crt_isatty.c
/* This program checks to see whether
 * stdout has been redirected to a file.
 */

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

int 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");
}

Sample Output

stdout has not been redirected to a file

See Also

File Handling Routines | Run-Time Routines and .NET Framework Equivalents

Show:
© 2016 Microsoft