1STDIO(3)                   Linux Programmer's Manual                  STDIO(3)
2
3
4

NAME

6       stdio - standard input/output library functions
7

SYNOPSIS

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

DESCRIPTION

16       The  standard  I/O  library  provides  a  simple and efficient buffered
17       stream I/O interface.  Input and output is  mapped  into  logical  data
18       streams  and  the physical I/O characteristics are concealed. The func‐
19       tions and macros are listed below; more information is  available  from
20       the individual man pages.
21
22       A  stream  is associated with an external file (which may be a physical
23       device) by opening a file, which may involve creating a new file.  Cre‐
24       ating  an existing file causes its former contents to be discarded.  If
25       a file can support positioning  requests  (such  as  a  disk  file,  as
26       opposed  to  a terminal) then a file position indicator associated with
27       the stream is positioned at the start of the file (byte  zero),  unless
28       the  file  is  opened  with  append mode. If append mode is used, it is
29       unspecified whether the position indicator will be placed at the  start
30       or the end of the file.  The position indicator is maintained by subse‐
31       quent reads, writes and positioning requests. All input  occurs  as  if
32       the  characters were read by successive calls to the fgetc(3) function;
33       all output takes place as if all characters were written by  successive
34       calls to the fputc(3) function.
35
36       A  file  is  disassociated  from  a stream by closing the file.  Output
37       streams are flushed (any unwritten buffer contents are  transferred  to
38       the host environment) before the stream is disassociated from the file.
39       The value of a pointer to a FILE object is indeterminate after  a  file
40       is closed (garbage).
41
42       A  file  may  be  subsequently reopened, by the same or another program
43       execution, and its contents reclaimed or modified (if it can be reposi‐
44       tioned  at  the  start).   If the main function returns to its original
45       caller, or the exit(3) function is called, all open  files  are  closed
46       (hence  all  output  streams  are  flushed) before program termination.
47       Other methods of program termination, such as abort(3)  do  not  bother
48       about closing files properly.
49
50       At  program  startup, three text streams are predefined and need not be
51       opened explicitly — standard input (for reading conventional input),  —
52       standard  output  (for  writing conventional input), and standard error
53       (for  writing  diagnostic  output).   These  streams  are   abbreviated
54       stdin,stdout and stderr.  When opened, the standard error stream is not
55       fully buffered;  the  standard  input  and  output  streams  are  fully
56       buffered  if  and only if the streams do not to refer to an interactive
57       device.
58
59       Output streams that refer to terminal devices are always line  buffered
60       by  default;  pending  output  to such streams is written automatically
61       whenever an input stream that refers to a terminal device is read.   In
62       cases  where  a large amount of computation is done after printing part
63       of a line on an output terminal, it is necessary to fflush(3) the stan‐
64       dard  output  before  going  off  and computing so that the output will
65       appear.
66
67       The stdio library is a part of the library libc and routines are  auto‐
68       matically  loaded as needed by the compilers cc(1) and pc(1).  The SYN‐
69       OPSIS sections of the following manual  pages  indicate  which  include
70       files  are  to  be used, what the compiler declaration for the function
71       looks like and which external variables are of interest.
72
73       The following are defined as macros; these names  may  not  be  re-used
74       without  first  removing their current definitions with #undef: BUFSIZ,
75       EOF, FILENAME_MAX, FOPEN_MAX,  L_cuserid,  L_ctermid,  L_tmpnam,  NULL,
76       SEEK_END,  SEEK_SET,  SEE_CUR, TMP_MAX, clearerr, feof, ferror, fileno,
77       getc, getchar, putc, putchar, stderr, stdin, stdout.  Function versions
78       of  the  macro functions feof, ferror, clearerr, fileno, getc, getchar,
79       putc, and putchar exist and will be used if the macros definitions  are
80       explicitly removed.
81

LIST OF FUNCTIONS

83       Function  Description
84
85       clearerr  check and reset stream status
86
87       fclose    close a stream
88
89       fdopen    stream open functions
90
91       feof      check and reset stream status
92
93       ferror    check and reset stream status
94
95       fflush    flush a stream
96
97       fgetc     get next character or word from input stream
98
99       fgetpos   reposition a stream
100
101       fgets     get a line from a stream
102
103       fileno    return the integer descriptor of the argument stream
104
105       fopen     stream open functions
106
107       fprintf   formatted output conversion
108
109       fpurge    flush a stream
110
111       fputc     output a character or word to a stream
112
113       fputs     output a line to a stream
114
115       fread     binary stream input/output
116
117       freopen   stream open functions
118
119       fscanf    input format conversion
120
121       fseek     reposition a stream
122
123       fsetpos   reposition a stream
124
125       ftell     reposition a stream
126
127       fwrite    binary stream input/output
128
129       getc      get next character or word from input stream
130
131       getchar   get next character or word from input stream
132
133       gets      get a line from a stream
134
135       getw      get next character or word from input stream
136
137       mktemp    make temporary filename (unique)
138
139       perror    system error messages
140
141       printf    formatted output conversion
142
143       putc      output a character or word to a stream
144
145       putchar   output a character or word to a stream
146
147       puts      output a line to a stream
148
149       putw      output a character or word to a stream
150
151       remove    remove directory entry
152
153       rewind    reposition a stream
154
155       scanf     input format conversion
156
157       setbuf    stream buffering operations
158
159       setbuffer stream buffering operations
160
161       setlinebuf
162                 stream buffering operations
163
164       setvbuf   stream buffering operations
165
166       sprintf   formatted output conversion
167
168       sscanf    input format conversion
169
170       strerror  system error messages
171
172       sys_errlist
173                 system error messages
174
175       sys_nerr  system error messages
176
177       tempnam   temporary file routines
178
179       tmpfile   temporary file routines
180
181       tmpnam    temporary file routines
182
183       ungetc    un-get character from input stream
184
185       vfprintf  formatted output conversion
186
187       vfscanf   input format conversion
188
189       vprintf   formatted output conversion
190
191       vscanf    input format conversion
192
193       vsprintf  formatted output conversion
194
195       vsscanf   input format conversion
196

CONFORMING TO

198       The stdio library conforms to C89.
199

SEE ALSO

201       close(2), open(2), read(2), write(2), stdout(3), unlocked_stdio(3)
202
203
204
205                                  2001-12-26                          STDIO(3)
Impressum