FAT | RFS | XFS | ZFS

fileno()

PROTOTYPE

#include <posix.h>

int fileno(FILE *file);

DESCRIPTION

fileno() returns a file descriptor that references the same file control block as file. fileno() performs the inverse of fdopen2().

If successful, fileno() returns the file descriptor corresponding to the specified file pointer. Otherwise, it sets errno and returns -1.

ERROR CODES

EBADF file is not the handle of an open file.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Get file ID for stdout and use it to write "Hello\n".             */
  /*-------------------------------------------------------------------*/
  fid = fileno(stdout);
  write(fid, "Hello\n", 6);