|
|
1.1 ! root 1: ! 2: ! 3: fileno() STDIO Function fileno() ! 4: ! 5: ! 6: ! 7: ! 8: Get file descriptor ! 9: ! 10: #include <stdio.h> ! 11: iinntt ffiilleennoo(_f_p) FFIILLEE *_f_p; ! 12: ! 13: fileno returns the file descriptor associated with the file ! 14: stream fp. The file descriptor is the integer returned by open ! 15: or creat. It is used by routines such as fopen to create a FFIILLEE ! 16: stream. ! 17: ! 18: ***** Example ***** ! 19: ! 20: This example reads a file descriptor and prints it on the screen. ! 21: ! 22: ! 23: #include <stdio.h> ! 24: ! 25: ! 26: ! 27: main(argc,argv) ! 28: int argc; char *argv[]; ! 29: { ! 30: FILE *fp; ! 31: int fd; ! 32: ! 33: ! 34: ! 35: if (argc !=2) { ! 36: printf("Usage: fd_from_fp filename\n"); ! 37: exit(0); ! 38: } ! 39: ! 40: ! 41: ! 42: if ((fp = fopen(argv[1], "r")) == NULL) { ! 43: printf("Cannot open input file\n"); ! 44: exit(0); ! 45: } ! 46: ! 47: ! 48: ! 49: fd = fileno(fp); ! 50: printf("The file descriptor for %s is %d\n", ! 51: argv[1], fd); ! 52: } ! 53: ! 54: ! 55: ***** See Also ***** ! 56: ! 57: FILE, file descriptor, STDIO ! 58: ! 59: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.