fileno

Returns the file descriptor associated with the specified stream.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  int fileno (
     FILE   *fp);
  

Parameters

fp

(IN) Points to a stream opened with a previous call to fopen, freopen, or fdopen.

Return Values

If successful, returns the integer file descriptor associated with the stream. Otherwise, returns -1 and sets errno to the following:

Decimal

Constant

Description

4

EBADF

Bad file number.

Remarks

The returned file descriptor can be used to access the stream with any of the functions that take a file descriptor.

See Also