|
|
1.1 ! root 1: .TH STDIO 3S ! 2: .CT 2 file_io ! 3: .SH NAME ! 4: stdio \(mi standard buffered input/output package ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .B #include <stdio.h> ! 8: .PP ! 9: .B FILE *stdin; ! 10: .B FILE *stdout; ! 11: .B FILE *stderr; ! 12: .fi ! 13: .SH DESCRIPTION ! 14: The functions described in Sections 3S constitute an efficient ! 15: user-level buffering scheme. ! 16: The in-line macros ! 17: .IR getc (3) ! 18: and ! 19: .IR putc ! 20: handle characters quickly. ! 21: The higher level routines ! 22: .I "fgets, scanf, fscanf, fread," ! 23: .I "puts, fputs, printf, fprintf, fwrite" ! 24: all use ! 25: .I getc ! 26: and ! 27: .I putc; ! 28: they can be freely intermixed. ! 29: .PP ! 30: A file with associated buffering is called a ! 31: .I stream, ! 32: and is declared to be a pointer to a defined type ! 33: .BR FILE . ! 34: .IR Fopen (3) ! 35: creates certain descriptive data for a stream ! 36: and returns a pointer to designate the stream in all ! 37: further transactions. ! 38: There are three normally open streams with constant ! 39: pointers declared in ! 40: the include file and associated with the standard open files: ! 41: .TP 10n ! 42: .BR stdin ! 43: standard input file ! 44: .br ! 45: .ns ! 46: .TP ! 47: .B stdout ! 48: standard output file ! 49: .br ! 50: .ns ! 51: .TP ! 52: .BR stderr ! 53: standard error file ! 54: .PP ! 55: A constant pointer ! 56: .L ! 57: NULL ! 58: designates no stream at all. ! 59: .PP ! 60: An integer constant ! 61: .B EOF ! 62: is returned ! 63: upon end of file or error by integer functions that ! 64: deal with streams. ! 65: .PP ! 66: Any routine that uses the standard input/output package ! 67: must include the header file ! 68: .F <stdio.h> ! 69: of pertinent ! 70: macro definitions. ! 71: The functions and constants mentioned in sections labeled 3S ! 72: are declared in the include file ! 73: and need no further declaration. ! 74: The constants, and the following `functions' are ! 75: implemented as macros: ! 76: .I getc, ! 77: .I getchar, ! 78: .I putc, ! 79: .I putchar, ! 80: .I feof, ! 81: .I ferror, ! 82: .IR fileno . ! 83: .SH "SEE ALSO" ! 84: .IR printf (3), ! 85: .IR scanf (3), ! 86: .IR fopen (3), ! 87: .IR getc (3), ! 88: .IR fgets (3), ! 89: .IR fread (3), ! 90: .IR fseek (3), ! 91: .IR ungetc (3), ! 92: .IR popen (3), ! 93: .IR setbuf (3), ! 94: .IR ferror (3) ! 95: .br ! 96: .IR open (2), ! 97: .IR read (2), ! 98: .IR fio (3) ! 99: .SH DIAGNOSTICS ! 100: The value ! 101: .B EOF ! 102: is returned uniformly to indicate that a ! 103: .B FILE ! 104: pointer has not been initialized with ! 105: .I fopen, ! 106: input (output) has been attempted on an output (input) stream, ! 107: or a ! 108: .B FILE ! 109: pointer designates corrupt or otherwise unintelligible ! 110: .B FILE ! 111: data. ! 112: .SH BUGS ! 113: Buffering of output can prevent output data ! 114: from being seen until long after it is computed \- perhaps ! 115: never, as when an abort occurs between buffer filling and flushing. ! 116: .br ! 117: Buffering of input can cause a process to consume ! 118: more input than it actually uses. ! 119: This can cause trouble across ! 120: .IR exec (2) ! 121: or ! 122: .IR system (3) ! 123: calls.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.