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


int _isatty(
   int 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.


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


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.


All versions of the C run-time libraries.


// 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" );
      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

© 2016 Microsoft