1stdio.h(0P)                POSIX Programmer's Manual               stdio.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       stdio.h — standard buffered input/output
14

SYNOPSIS

16       #include <stdio.h>
17

DESCRIPTION

19       Some of the functionality described on this reference page extends  the
20       ISO C  standard. Applications shall define the appropriate feature test
21       macro (see the System Interfaces volume of POSIX.1‐2008,  Section  2.2,
22       The  Compilation Environment) to enable the visibility of these symbols
23       in this header.
24
25       The <stdio.h> header shall define  the  following  data  types  through
26       typedef:
27
28       FILE          A structure containing information about a file.
29
30       fpos_t        A  non-array  type  containing  all information needed to
31                     specify uniquely every position within a file.
32
33       off_t         As described in <sys/types.h>.
34
35       size_t        As described in <stddef.h>.
36
37       ssize_t       As described in <sys/types.h>.
38
39       va_list       As described in <stdarg.h>.
40
41       The <stdio.h> header shall define  the  following  macros  which  shall
42       expand to integer constant expressions:
43
44       BUFSIZ        Size  of <stdio.h> buffers.  This shall expand to a posi‐
45                     tive value.
46
47       L_ctermid     Maximum size of character array to hold ctermid() output.
48
49       L_tmpnam      Maximum size of character array to hold tmpnam() output.
50
51       The <stdio.h> header shall define  the  following  macros  which  shall
52       expand to integer constant expressions with distinct values:
53
54       _IOFBF        Input/output fully buffered.
55
56       _IOLBF        Input/output line buffered.
57
58       _IONBF        Input/output unbuffered.
59
60       The  <stdio.h>  header  shall  define  the following macros which shall
61       expand to integer constant expressions with distinct values:
62
63       SEEK_CUR      Seek relative to current position.
64
65       SEEK_END      Seek relative to end-of-file.
66
67       SEEK_SET      Seek relative to start-of-file.
68
69       The <stdio.h> header shall define  the  following  macros  which  shall
70       expand to integer constant expressions denoting implementation limits:
71
72       {FILENAME_MAX}
73                     Maximum  size  in  bytes of the longest pathname that the
74                     implementation guarantees can be opened.
75
76       {FOPEN_MAX}   Number of streams which the implementation guarantees can
77                     be open simultaneously. The value is at least eight.
78
79       {TMP_MAX}     Minimum number of unique filenames generated by tmpnam().
80                     Maximum number of times an application can call  tmpnam()
81                     reliably. The value of {TMP_MAX} is at least 25.
82
83                     On  XSI-conformant  systems, the value of {TMP_MAX} is at
84                     least 10000.
85
86       The <stdio.h> header shall  define  the  following  macro  which  shall
87       expand  to  an integer constant expression with type int and a negative
88       value:
89
90       EOF           End-of-file return value.
91
92       The <stdio.h> header shall define NULL as described in <stddef.h>.
93
94       The <stdio.h> header shall  define  the  following  macro  which  shall
95       expand to a string constant:
96
97       P_tmpdir      Default directory prefix for tempnam().
98
99       The  <stdio.h>  header  shall  define  the following macros which shall
100       expand to expressions of type ``pointer to FILE''  that  point  to  the
101       FILE  objects associated, respectively, with the standard error, input,
102       and output streams:
103
104       stderr        Standard error output stream.
105
106       stdin         Standard input stream.
107
108       stdout        Standard output stream.
109
110       The following shall be declared as functions and may also be defined as
111       macros. Function prototypes shall be provided.
112
113           void     clearerr(FILE *);
114           char    *ctermid(char *);
115           int      dprintf(int, const char *restrict, ...)
116           int      fclose(FILE *);
117           FILE    *fdopen(int, const char *);
118           int      feof(FILE *);
119           int      ferror(FILE *);
120           int      fflush(FILE *);
121           int      fgetc(FILE *);
122           int      fgetpos(FILE *restrict, fpos_t *restrict);
123           char    *fgets(char *restrict, int, FILE *restrict);
124           int      fileno(FILE *);
125           void     flockfile(FILE *);
126           FILE    *fmemopen(void *restrict, size_t, const char *restrict);
127           FILE    *fopen(const char *restrict, const char *restrict);
128           int      fprintf(FILE *restrict, const char *restrict, ...);
129           int      fputc(int, FILE *);
130           int      fputs(const char *restrict, FILE *restrict);
131           size_t   fread(void *restrict, size_t, size_t, FILE *restrict);
132           FILE    *freopen(const char *restrict, const char *restrict,
133                        FILE *restrict);
134           int      fscanf(FILE *restrict, const char *restrict, ...);
135           int      fseek(FILE *, long, int);
136           int      fseeko(FILE *, off_t, int);
137           int      fsetpos(FILE *, const fpos_t *);
138           long     ftell(FILE *);
139           off_t    ftello(FILE *);
140           int      ftrylockfile(FILE *);
141           void     funlockfile(FILE *);
142           size_t   fwrite(const void *restrict, size_t, size_t, FILE *restrict);
143           int      getc(FILE *);
144           int      getchar(void);
145           int      getc_unlocked(FILE *);
146           int      getchar_unlocked(void);
147           ssize_t  getdelim(char **restrict, size_t *restrict, int,
148                        FILE *restrict);
149           ssize_t  getline(char **restrict, size_t *restrict, FILE *restrict);
150           char    *gets(char *);
151           FILE    *open_memstream(char **, size_t *);
152           int      pclose(FILE *);
153           void     perror(const char *);
154           FILE    *popen(const char *, const char *);
155           int      printf(const char *restrict, ...);
156           int      putc(int, FILE *);
157           int      putchar(int);
158           int      putc_unlocked(int, FILE *);
159           int      putchar_unlocked(int);
160           int      puts(const char *);
161           int      remove(const char *);
162           int      rename(const char *, const char *);
163           int      renameat(int, const char *, int, const char *);
164           void     rewind(FILE *);
165           int      scanf(const char *restrict, ...);
166           void     setbuf(FILE *restrict, char *restrict);
167           int      setvbuf(FILE *restrict, char *restrict, int, size_t);
168           int      snprintf(char *restrict, size_t, const char *restrict, ...);
169           int      sprintf(char *restrict, const char *restrict, ...);
170           int      sscanf(const char *restrict, const char *restrict, ...);
171           char    *tempnam(const char *, const char *);
172           FILE    *tmpfile(void);
173           char    *tmpnam(char *);
174           int      ungetc(int, FILE *);
175           int      vdprintf(int, const char *restrict, va_list);
176           int      vfprintf(FILE *restrict, const char *restrict, va_list);
177           int      vfscanf(FILE *restrict, const char *restrict, va_list);
178           int      vprintf(const char *restrict, va_list);
179           int      vscanf(const char *restrict, va_list);
180           int      vsnprintf(char *restrict, size_t, const char *restrict,
181                        va_list);
182           int      vsprintf(char *restrict, const char *restrict, va_list);
183           int      vsscanf(const char *restrict, const char *restrict, va_list);
184
185       Inclusion  of  the  <stdio.h>  header may also make visible all symbols
186       from <stddef.h>.
187
188       The following sections are informative.
189

APPLICATION USAGE

191       Since standard I/O streams may use an  underlying  file  descriptor  to
192       access  the  file associated with a stream, application developers need
193       to be aware that {FOPEN_MAX} streams  may  not  be  available  if  file
194       descriptors are being used to access files that are not associated with
195       streams.
196

RATIONALE

198       There is a conflict between the ISO C standard and the POSIX definition
199       of the {TMP_MAX} macro that is addressed by ISO/IEC 9899:1999 standard,
200       Defect Report 336. The POSIX standard is in alignment with  the  public
201       record  of  the response to the Defect Report.  This change has not yet
202       been published as part of the ISO C standard.
203

FUTURE DIRECTIONS

205       None.
206

SEE ALSO

208       <stdarg.h>, <stddef.h>, <sys_types.h>
209
210       The System Interfaces volume of POSIX.1‐2008, Section 2.2, The Compila‐
211       tion Environment, clearerr(), ctermid(), fclose(), fdopen(), feof(),
212       ferror(), fflush(), fgetc(), fgetpos(), fgets(), fileno(), flockfile(),
213       fmemopen(), fopen(), fprintf(), fputc(), fputs(), fread(), freopen(),
214       fscanf(), fseek(), fsetpos(), ftell(), fwrite(), getc(), getchar(),
215       getc_unlocked(), getdelim(), getopt(), gets(), open_memstream(),
216       pclose(), perror(), popen(), putc(), putchar(), puts(), remove(),
217       rename(), rewind(), setbuf(), setvbuf(), stdin, system(), tempnam(),
218       tmpfile(), tmpnam(), ungetc(), vfprintf(), vfscanf()
219
221       Portions of this text are reprinted and reproduced in  electronic  form
222       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
223       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
224       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
225       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
226       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
227       event of any discrepancy between this version and the original IEEE and
228       The  Open Group Standard, the original IEEE and The Open Group Standard
229       is the referee document. The original Standard can be  obtained  online
230       at http://www.unix.org/online.html .
231
232       Any  typographical  or  formatting  errors that appear in this page are
233       most likely to have been introduced during the conversion of the source
234       files  to  man page format. To report such errors, see https://www.ker
235       nel.org/doc/man-pages/reporting_bugs.html .
236
237
238
239IEEE/The Open Group                  2013                          stdio.h(0P)
Impressum