|
|
coherent
fileno() STDIO Function fileno()
Get file descriptor
#include <stdio.h>
iinntt ffiilleennoo(_f_p) FFIILLEE *_f_p;
fileno returns the file descriptor associated with the file
stream fp. The file descriptor is the integer returned by open
or creat. It is used by routines such as fopen to create a FFIILLEE
stream.
***** 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, STDIO
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.