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  reused
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, SEEK_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
82   List of Functions
83       Function      Description
84       ───────────────────────────────────────────────────────────────────
85       clearerr      check and reset stream status
86       fclose        close a stream
87       fdopen        stream open functions
88       feof          check and reset stream status
89       ferror        check and reset stream status
90       fflush        flush a stream
91       fgetc         get next character or word from input stream
92       fgetpos       reposition a stream
93       fgets         get a line from a stream
94       fileno        return the integer descriptor of the argument stream
95       fopen         stream open functions
96       fprintf       formatted output conversion
97       fpurge        flush a stream
98       fputc         output a character or word to a stream
99       fputs         output a line to a stream
100       fread         binary stream input/output
101       freopen       stream open functions
102       fscanf        input format conversion
103       fseek         reposition a stream
104       fsetpos       reposition a stream
105       ftell         reposition a stream
106       fwrite        binary stream input/output
107       getc          get next character or word from input stream
108       getchar       get next character or word from input stream
109       gets          get a line from a stream
110       getw          get next character or word from input stream
111       mktemp        make temporary filename (unique)
112       perror        system error messages
113       printf        formatted output conversion
114       putc          output a character or word to a stream
115       putchar       output a character or word to a stream
116       puts          output a line to a stream
117       putw          output a character or word to a stream
118       remove        remove directory entry
119       rewind        reposition a stream
120       scanf         input format conversion
121       setbuf        stream buffering operations
122       setbuffer     stream buffering operations
123       setlinebuf    stream buffering operations
124       setvbuf       stream buffering operations
125       sprintf       formatted output conversion
126       sscanf        input format conversion
127       strerror      system error messages
128       sys_errlist   system error messages
129       sys_nerr      system error messages
130       tempnam       temporary file routines
131       tmpfile       temporary file routines
132
133       tmpnam        temporary file routines
134       ungetc        un-get character from input stream
135       vfprintf      formatted output conversion
136       vfscanf       input format conversion
137       vprintf       formatted output conversion
138       vscanf        input format conversion
139       vsprintf      formatted output conversion
140       vsscanf       input format conversion
141

CONFORMING TO

143       The stdio library conforms to C89.
144

SEE ALSO

146       close(2), open(2), read(2), write(2), stdout(3), unlocked_stdio(3)
147

COLOPHON

149       This  page  is  part of release 3.25 of the Linux man-pages project.  A
150       description of the project, and information about reporting  bugs,  can
151       be found at http://www.kernel.org/doc/man-pages/.
152
153
154
155                                  2001-12-26                          STDIO(3)
Impressum