ffiilleennoo() -- STDIO Function (libc)

Get file descriptor
#iinncclluuddee <ssttddiioo.hh>
iinntt ffiilleennoo(_f_p) FFIILLEE *_f_p;

ffiilleennoo() returns  the file descriptor  associated with the  file stream _f_p.
The  file descriptor  is  the integer  returned  by ooppeenn()  or ccrreeaatt();  it
corresponds to a FFIILLEE structure, as returned by the STDIO function ffooppeenn().

_E_x_a_m_p_l_e
This example reads a file descriptor and prints it on the screen.

#include <stdio.h>

main(argc,argv)
int argc; char *argv[];
{
    FILE *fp;
    int fd;

    if (argc !=2) {
        printf("Usage: fd_from_fp filename\n");
        exit(0);
    }

    if ((fp = fopen(argv[1], "r")) == NULL) {
        printf("Cannot open input file\n");
        exit(0);
    }

    fd = fileno(fp);
    printf("The file descriptor for %s is %d\n",
        argv[1], fd);
}

_S_e_e _A_l_s_o
FFIILLEE, ffiillee ddeessccrriippttoorr, lliibbcc
POSIX Standard, section 8.2.1
