COHERENT manpages
This page displays the COHERENT manpage for fileno() [Get file descriptor].
List of available manpages
Index
fileno() -- STDIO Function (libc) Get file descriptor #include <stdio.h> int fileno(fp) FILE *fp; fileno() returns the file descriptor associated with the file stream fp. The file descriptor is the integer returned by open() or creat(); it corresponds to a FILE structure, as returned by the STDIO function fopen(). Example 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); } See Also FILE, file descriptor, libc POSIX Standard, §8.2.1