Syntax
#include <stdio.h> int fileno(FILE *stream);Description
fileno determines the file handle currently associated with stream.
Note: In earlier releases of C Set ++, fileno began with an underscore (_fileno). Because it is defined by the X/Open standard, the underscore has been removed. For compatibility, The Developer's Toolkit will map _fileno to fileno for you.
fileno returns the file handle. If the function fails, the return value is -1 and the errno variable may be set to one of the following values: compact break=fit.
Value
The result is undefined if stream does not specify an open file.
This example determines the file handle of the stderr data stream.
#include <stdio.h> int main(void) { int result; result = 0xFFFF & fileno(stderr); printf("The file handle associated with stderr is %d.\n", result); return 0; /**************************************************************************** The output should be: The file handle associated with stderr is 2. ****************************************************************************/ }Related Information