|
|
1.1 ! root 1: .TH INTRO 3S "18 July 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: stdio \- standard buffered input/output package ! 5: .SH SYNOPSIS ! 6: .B #include <stdio.h> ! 7: .PP ! 8: .SM ! 9: .B FILE ! 10: .B *stdin; ! 11: .br ! 12: .SM ! 13: .B FILE ! 14: .B *stdout; ! 15: .br ! 16: .SM ! 17: .B FILE ! 18: .B *stderr; ! 19: .SH DESCRIPTION ! 20: The functions described in section 3S constitute a user-level buffering ! 21: scheme. The in-line macros ! 22: .I getc ! 23: and ! 24: .IR putc (3S) ! 25: handle characters quickly. The higher level routines ! 26: .IR gets , ! 27: .IR fgets , ! 28: .IR scanf , ! 29: .IR fscanf , ! 30: .IR fread , ! 31: .IR puts , ! 32: .IR fputs , ! 33: .IR printf , ! 34: .IR fprintf , ! 35: .IR fwrite ! 36: all use ! 37: .I getc ! 38: and ! 39: .IR putc ; ! 40: they can be freely intermixed. ! 41: .PP ! 42: A file with associated buffering is called a ! 43: .IR stream , ! 44: and is declared to be a pointer to a defined type ! 45: .SM ! 46: .BR FILE . ! 47: .IR Fopen (3S) ! 48: creates certain descriptive data for a stream ! 49: and returns a pointer to designate the stream in all further transactions. ! 50: There are three normally open streams with constant pointers declared in ! 51: the include file and associated with the standard open files: ! 52: .TP 10n ! 53: .B stdin ! 54: standard input file ! 55: .br ! 56: .ns ! 57: .TP ! 58: .B stdout ! 59: standard output file ! 60: .br ! 61: .ns ! 62: .TP ! 63: .B stderr ! 64: standard error file ! 65: .PP ! 66: A constant `pointer' ! 67: .SM ! 68: .B NULL ! 69: (0) ! 70: designates no stream at all. ! 71: .PP ! 72: An integer constant ! 73: .SM ! 74: .B EOF ! 75: (\-1) is returned upon end of file or error by integer functions that ! 76: deal with streams. ! 77: .PP ! 78: Any routine that uses the standard input/output package ! 79: must include the header file ! 80: .RI < stdio.h > ! 81: of pertinent macro definitions. ! 82: The functions and constants mentioned in sections labeled 3S ! 83: are declared in the include file and need no further declaration. ! 84: The constants, and the following `functions' are ! 85: implemented as macros; redeclaration of these names is perilous: ! 86: .IR getc , ! 87: .IR getchar , ! 88: .IR putc , ! 89: .IR putchar , ! 90: .IR feof , ! 91: .IR ferror , ! 92: .IR fileno . ! 93: .SH "SEE ALSO" ! 94: open(2), close(2), read(2), write(2), fread(3S), fseek(3S), f*(3S) ! 95: .SH DIAGNOSTICS ! 96: The value ! 97: .SM ! 98: .B EOF ! 99: is returned uniformly to indicate that a ! 100: .SM ! 101: .B FILE ! 102: pointer has not been initialized with ! 103: .IR fopen , ! 104: input (output) has been attempted on an output (input) stream, or a ! 105: .SM ! 106: .B FILE ! 107: pointer designates corrupt or otherwise unintelligible ! 108: .SM ! 109: .B FILE ! 110: data. ! 111: .PP ! 112: For purposes of efficiency, this implementation of the standard library ! 113: has been changed to line buffer output to a terminal by default and attempts ! 114: to do this transparently by flushing the output whenever a ! 115: .IR read (2) ! 116: from the standard input is necessary. This is almost always transparent, ! 117: but may cause confusion or malfunctioning of programs which use ! 118: standard i/o routines but use ! 119: .IR read (2) ! 120: themselves to read from the standard input. ! 121: .PP ! 122: In cases where a large amount of computation is done after printing ! 123: part of a line on an output terminal, it is necessary to ! 124: .IR fflush (3S) ! 125: the standard output before going off and computing so that the output ! 126: will appear. ! 127: .SH BUGS ! 128: The standard buffered functions do not interact well with certain other ! 129: library and system functions, especially \fIvfork\fP and \fIabort\fP. ! 130: .SH "LIST OF FUNCTIONS" ! 131: .sp 2 ! 132: .nf ! 133: .ta \w'setlinebuf'u+2n +\w'setbuf.3s'u+10n ! 134: \fIName\fP \fIAppears on Page\fP \fIDescription\fP ! 135: .ta \w'setlinebuf'u+4n +\w'setbuf.3s'u+4n ! 136: .sp 5p ! 137: clearerr ferror.3s stream status inquiries ! 138: fclose fclose.3s close or flush a stream ! 139: fdopen fopen.3s open a stream ! 140: feof ferror.3s stream status inquiries ! 141: ferror ferror.3s stream status inquiries ! 142: fflush fclose.3s close or flush a stream ! 143: fgetc getc.3s get character or word from stream ! 144: fgets gets.3s get a string from a stream ! 145: fileno ferror.3s stream status inquiries ! 146: fopen fopen.3s open a stream ! 147: fprintf printf.3s formatted output conversion ! 148: fputc putc.3s put character or word on a stream ! 149: fputs puts.3s put a string on a stream ! 150: fread fread.3s buffered binary input/output ! 151: freopen fopen.3s open a stream ! 152: fscanf scanf.3s formatted input conversion ! 153: fseek fseek.3s reposition a stream ! 154: ftell fseek.3s reposition a stream ! 155: fwrite fread.3s buffered binary input/output ! 156: getc getc.3s get character or word from stream ! 157: getchar getc.3s get character or word from stream ! 158: gets gets.3s get a string from a stream ! 159: getw getc.3s get character or word from stream ! 160: printf printf.3s formatted output conversion ! 161: putc putc.3s put character or word on a stream ! 162: putchar putc.3s put character or word on a stream ! 163: puts puts.3s put a string on a stream ! 164: putw putc.3s put character or word on a stream ! 165: rewind fseek.3s reposition a stream ! 166: scanf scanf.3s formatted input conversion ! 167: setbuf setbuf.3s assign buffering to a stream ! 168: setbuffer setbuf.3s assign buffering to a stream ! 169: setlinebuf setbuf.3s assign buffering to a stream ! 170: sprintf printf.3s formatted output conversion ! 171: sscanf scanf.3s formatted input conversion ! 172: ungetc ungetc.3s push character back into input stream ! 173: .fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.