return the number of the file descriptor for a stream
#include <stdio.h> int fileno( FILE *stream );
The fileno() function returns the number of the file descriptor for the file designated by stream. This number can be used in POSIX input/output calls anywhere the value returned by open() can be used. The following symbolic values in <unistd.h> define the file descriptors that are associated with the C language stdin, stdout, and stderr files when the application is started.
The number of the file descriptor for the file designated by stream. If an error occurs, a value of -1 is returned, and errno is set to indicate the error.
#include <stdio.h>
void main()
{
FILE *stream;
stream = fopen( "file", "r" );
printf( "File number is %d\n", fileno( stream ) );
fclose( stream );
}
produces output similar to the following:
File number is 7
POSIX 1003.1
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |