1STDIO(3S)                                                            STDIO(3S)
2
3
4

NAME

6       stdio - standard buffered input/output package
7

SYNOPSIS

9       #include <stdio.h>
10
11       FILE *stdin;
12       FILE *stdout;
13       FILE *stderr;
14

DESCRIPTION

16       The functions described in section 3S constitute a user-level buffering
17       scheme.   The  in-line  macros  getc  and  putc(3S)  handle  characters
18       quickly.   The higher level routines gets, fgets, scanf, fscanf, fread,
19       puts, fputs, printf, fprintf, fwrite all use getc and putc; they can be
20       freely intermixed.
21
22       A file with associated buffering is called a stream, and is declared to
23       be a pointer  to  a  defined  type  FILE.   Fopen(3S)  creates  certain
24       descriptive  data  for  a stream and returns a pointer to designate the
25       stream in all further transactions.   There  are  three  normally  open
26       streams with constant pointers declared in the include file and associ‐
27       ated with the standard open files:
28
29       stdin     standard input file
30       stdout    standard output file
31       stderr    standard error file
32
33       A constant `pointer' NULL (0) designates no stream at all.
34
35       An integer constant EOF (-1) is returned upon end of file or  error  by
36       integer functions that deal with streams.
37
38       Any  routine  that  uses the standard input/output package must include
39       the header file <stdio.h> of pertinent macro  definitions.   The  func‐
40       tions  and  constants  mentioned in sections labeled 3S are declared in
41       the include file and need no further declaration.  The  constants,  and
42       the  following  `functions' are implemented as macros; redeclaration of
43       these names is perilous: getc, getchar, putc,  putchar,  feof,  ferror,
44       fileno.
45

SEE ALSO

47       open(2), close(2), read(2), write(2), fread(3S), fseek(3S), f*(3S)
48

DIAGNOSTICS

50       The value EOF is returned uniformly to indicate that a FILE pointer has
51       not been initialized with fopen, input (output) has been  attempted  on
52       an  output (input) stream, or a FILE pointer designates corrupt or oth‐
53       erwise unintelligible FILE data.
54
55       For purposes of efficiency, this implementation of the standard library
56       has  been  changed  to  line buffer output to a terminal by default and
57       attempts to do this transparently by flushing  the  output  whenever  a
58       read(2)  from  the  standard input is necessary.  This is almost always
59       transparent, but may cause  confusion  or  malfunctioning  of  programs
60       which use standard i/o routines but use read(2) themselves to read from
61       the standard input.
62
63       In cases where a large amount of computation  is  done  after  printing
64       part of a line on an output terminal, it is necessary to fflush(3S) the
65       standard output before going off and computing so that the output  will
66       appear.
67

BUGS

69       The standard buffered functions do not interact well with certain other
70       library and system functions, especially vfork and abort.
71

LIST OF FUNCTIONS

73       Name        Appears on Page    Description
74       clearerr      ferror.3s    stream status inquiries
75       fclose        fclose.3s    close or flush a stream
76       fdopen        fopen.3s     open a stream
77       feof          ferror.3s    stream status inquiries
78       ferror        ferror.3s    stream status inquiries
79       fflush        fclose.3s    close or flush a stream
80       fgetc         getc.3s      get character or word from stream
81       fgets         gets.3s      get a string from a stream
82       fileno        ferror.3s    stream status inquiries
83       fopen         fopen.3s     open a stream
84       fprintf       printf.3s    formatted output conversion
85       fputc         putc.3s      put character or word on a stream
86       fputs         puts.3s      put a string on a stream
87       fread         fread.3s     buffered binary input/output
88       freopen       fopen.3s     open a stream
89       fscanf        scanf.3s     formatted input conversion
90       fseek         fseek.3s     reposition a stream
91       ftell         fseek.3s     reposition a stream
92       fwrite        fread.3s     buffered binary input/output
93       getc          getc.3s      get character or word from stream
94       getchar       getc.3s      get character or word from stream
95       gets          gets.3s      get a string from a stream
96       getw          getc.3s      get character or word from stream
97       printf        printf.3s    formatted output conversion
98       putc          putc.3s      put character or word on a stream
99       putchar       putc.3s      put character or word on a stream
100       puts          puts.3s      put a string on a stream
101       putw          putc.3s      put character or word on a stream
102       rewind        fseek.3s     reposition a stream
103       scanf         scanf.3s     formatted input conversion
104       setbuf        setbuf.3s    assign buffering to a stream
105       setbuffer     setbuf.3s    assign buffering to a stream
106       setlinebuf    setbuf.3s    assign buffering to a stream
107       sprintf       printf.3s    formatted output conversion
108       sscanf        scanf.3s     formatted input conversion
109       ungetc        ungetc.3s    push character back into input stream
110
111
112
1134th Berkeley Distribution        May 13, 1986                        STDIO(3S)
Impressum