Next: fopen, Previous: fgets, Up: Stdio

### 4.11 `fileno`—return file descriptor associated with stream

Synopsis

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

Description
You can use `fileno` to return the file descriptor identified by fp.

Returns
`fileno` returns a non-negative integer when successful. If fp is not an open stream, `fileno` returns -1.

Portability
`fileno` is not part of ANSI C. POSIX requires `fileno`.

Supporting OS subroutines required: none.