Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 8
Return the file descriptor for a stream
#include <stdio.h>
int fileno( FILE * stream );
- stream
- The stream whose file descriptor you want to find.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The fileno() function returns the file descriptor for the specified file stream.
This file descriptor can be used in POSIX input/output calls anywhere the value returned by
open()
can be used.
To associate a stream with a file descriptor, call
fdopen().
|
In QNX Neutrino, the file descriptor is also the connection ID
(coid) used by various Neutrino-specific functions. |
The following symbolic values in <unistd.h>
define the file descriptors associated with the C language
stdin,
stdout,
and
stderr
streams:
- STDIN_FILENO
- Standard input file number, stdin (0)
- STDOUT_FILENO
- Standard output file number, stdout (1)
- STDERR_FILENO
- Standard error file number, stderr (2)
A file descriptor, or -1 if an error occurs
(errno is
set).
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
FILE *stream;
stream = fopen( "file", "r" );
if( stream != NULL ) {
printf( "File number is %d.\n", fileno( stream ) );
fclose( stream );
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
Produces output similar to:
File number is 7.
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
errno,
fdopen(),
fopen(),
open()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 189
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/f/fileno.html on line 189