_fileno

This is preliminary documentation and subject to change.

_fileno

Gets the file handle associated with a stream.

Function Required Header
_fileno <stdio.h>
int _fileno( FILE *stream );

Parameters

  • stream
    Pointer to FILE structure

Libraries

All versions of the C run-time libraries.

Return Values

_fileno returns the file handle. There is no error return. The result is undefined if stream does not specify an open file.

Remarks

The _fileno routine returns the file handle currently associated with stream. This routine is implemented both as a function and as a macro. For details on choosing either implementation, see Choosing Between Functions and Macros.

Example

/* FILENO.C: This program uses _fileno to obtain
 * the file handle for some standard C streams.
 */

#include <stdio.h>

void main( void )
{
   printf( "The file handle for stdin is %d\n", _fileno( stdin ) );
   printf( "The file handle for stdout is %d\n", _fileno( stdout ) );
   printf( "The file handle for stderr is %d\n", _fileno( stderr ) );
}

Output

The file handle for stdin is 0
The file handle for stdout is 1
The file handle for stderr is 2

See Also

fopen