[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


fileno

Obtains the file descriptor associated with a stream.

Compatibility:

This function is compatible with the following targets:

ANSI
BeOS
EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <unix.h>
int fileno(FILE *stream);
Parameters:

Parameters for this facility are:

stream  
FILE *  
A pointer to a FILE stream  

Remarks:

This function obtains the file descriptor for the stream. You can use the file descriptor with other functions in unix.h, such as read() and write().

For the standard I/O streams stdin, stdout, and stderr, fileno() returns the following values:

File Descriptors for the Standard I/O Streams:

This function call
Returns this file descriptor
fileno(stdin)  
0  
fileno(stdout)  
1  
fileno(stderr)  
2  

Return:

If it is successful, fileno() returns a file descriptor. If it encounters an error, it returns -1 and sets errno.

See Also:

"fdopen"

"open"

Example of fileno() usage.:
#include <unix.h>
#include <stdio.h>

int main(void)
{
	printf("The handle for the standard input device is: %d",
				 fileno(stdin) );

	return 0;
}

Reult
The handle for the standard input device is: 0


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000