1STDIO(3S) STDIO(3S)
2
3
4
6 stdio - standard buffered input/output package
7
9 #include <stdio.h>
10
11 FILE *stdin;
12 FILE *stdout;
13 FILE *stderr;
14
16 The functions described in Sections 3S constitute an efficient user-
17 level buffering scheme. The in-line macros getc and putc(3) handle
18 characters quickly. The higher level routines gets, fgets, scanf,
19 fscanf, fread, puts, fputs, printf, fprintf, fwrite all use getc and
20 putc; they can be 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. [22mFopen(3) creates certain descrip‐
24 tive data for a stream and returns a pointer to designate the stream in
25 all further transactions. There are three normally open streams with
26 constant pointers declared in the include file and associated with the
27 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
47 open(2), close(2), read(2), write(2)
48
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
56
57 STDIO(3S)