1<stdio.h>(0P) POSIX Programmer's Manual <stdio.h>(0P)
2
3
4
6 stdio.h - standard buffered input/output
7
9 #include <stdio.h>
10
12 Some of the functionality described on this reference page extends the
13 ISO C standard. Applications shall define the appropriate feature test
14 macro (see the System Interfaces volume of IEEE Std 1003.1-2001, Sec‐
15 tion 2.2, The Compilation Environment) to enable the visibility of
16 these symbols in this header.
17
18 The <stdio.h> header shall define the following macros as positive
19 integer constant expressions:
20
21 BUFSIZ Size of <stdio.h> buffers.
22
23 _IOFBF Input/output fully buffered.
24
25 _IOLBF Input/output line buffered.
26
27 _IONBF Input/output unbuffered.
28
29 L_ctermid
30 Maximum size of character array to hold ctermid() output.
31
32 L_tmpnam
33 Maximum size of character array to hold tmpnam() output.
34
35 SEEK_CUR
36 Seek relative to current position.
37
38 SEEK_END
39 Seek relative to end-of-file.
40
41 SEEK_SET
42 Seek relative to start-of-file.
43
44
45 The following macros shall be defined as positive integer constant
46 expressions which denote implementation limits:
47
48 {FILENAME_MAX}
49 Maximum size in bytes of the longest filename string that the
50 implementation guarantees can be opened.
51
52 {FOPEN_MAX}
53 Number of streams which the implementation guarantees can be
54 open simultaneously. The value is at least eight.
55
56 {TMP_MAX}
57 Minimum number of unique filenames generated by tmpnam(). Maxi‐
58 mum number of times an application can call tmpnam() reliably.
59 The value of {TMP_MAX} is at least 25. On XSI-conformant sys‐
60 tems, the value of {TMP_MAX} is at least 10000.
61
62
63 The following macro name shall be defined as a negative integer con‐
64 stant expression:
65
66 EOF End-of-file return value.
67
68
69 The following macro name shall be defined as a null pointer constant:
70
71 NULL Null pointer.
72
73
74 The following macro name shall be defined as a string constant:
75
76 P_tmpdir
77 Default directory prefix for tempnam().
78
79
80 The following shall be defined as expressions of type "pointer to FILE"
81 that point to the FILE objects associated, respectively, with the stan‐
82 dard error, input, and output streams:
83
84 stderr Standard error output stream.
85
86 stdin Standard input stream.
87
88 stdout Standard output stream.
89
90
91 The following data types shall be defined through typedef:
92
93 FILE A structure containing information about a file.
94
95 fpos_t A non-array type containing all information needed to specify
96 uniquely every position within a file.
97
98 va_list
99 As described in <stdarg.h> .
100
101 size_t As described in <stddef.h> .
102
103
104 The following shall be declared as functions and may also be defined as
105 macros. Function prototypes shall be provided.
106
107
108 void clearerr(FILE *);
109
110 char *ctermid(char *);
111
112 int fclose(FILE *);
113
114 FILE *fdopen(int, const char *);
115
116 int feof(FILE *);
117 int ferror(FILE *);
118 int fflush(FILE *);
119 int fgetc(FILE *);
120 int fgetpos(FILE *restrict, fpos_t *restrict);
121 char *fgets(char *restrict, int, FILE *restrict);
122
123 int fileno(FILE *);
124
125
126 void flockfile(FILE *);
127
128 FILE *fopen(const char *restrict, const char *restrict);
129 int fprintf(FILE *restrict, const char *restrict, ...);
130 int fputc(int, FILE *);
131 int fputs(const char *restrict, FILE *restrict);
132 size_t fread(void *restrict, size_t, size_t, FILE *restrict);
133 FILE *freopen(const char *restrict, const char *restrict,
134 FILE *restrict);
135 int fscanf(FILE *restrict, const char *restrict, ...);
136 int fseek(FILE *, long, int);
137
138 int fseeko(FILE *, off_t, int);
139
140 int fsetpos(FILE *, const fpos_t *);
141 long ftell(FILE *);
142
143 off_t ftello(FILE *);
144
145
146 int ftrylockfile(FILE *);
147 void funlockfile(FILE *);
148
149 size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
150 int getc(FILE *);
151 int getchar(void);
152
153 int getc_unlocked(FILE *);
154 int getchar_unlocked(void);
155
156 char *gets(char *);
157
158 int pclose(FILE *);
159
160 void perror(const char *);
161
162 FILE *popen(const char *, const char *);
163
164 int printf(const char *restrict, ...);
165 int putc(int, FILE *);
166 int putchar(int);
167
168 int putc_unlocked(int, FILE *);
169 int putchar_unlocked(int);
170
171 int puts(const char *);
172 int remove(const char *);
173 int rename(const char *, const char *);
174 void rewind(FILE *);
175 int scanf(const char *restrict, ...);
176 void setbuf(FILE *restrict, char *restrict);
177 int setvbuf(FILE *restrict, char *restrict, int, size_t);
178 int snprintf(char *restrict, size_t, const char *restrict, ...);
179 int sprintf(char *restrict, const char *restrict, ...);
180 int sscanf(const char *restrict, const char *restrict, int ...);
181
182 char *tempnam(const char *, const char *);
183
184 FILE *tmpfile(void);
185 char *tmpnam(char *);
186 int ungetc(int, FILE *);
187 int vfprintf(FILE *restrict, const char *restrict, va_list);
188 int vfscanf(FILE *restrict, const char *restrict, va_list);
189 int vprintf(const char *restrict, va_list);
190 int vscanf(const char *restrict, va_list);
191 int vsnprintf(char *restrict, size_t, const char *restrict, va_list;
192 int vsprintf(char *restrict, const char *restrict, va_list);
193 int vsscanf(const char *restrict, const char *restrict, va_list arg);
194
195 Inclusion of the <stdio.h> header may also make visible all symbols
196 from <stddef.h>.
197
198 The following sections are informative.
199
201 None.
202
204 None.
205
207 None.
208
210 <stdarg.h>, <stddef.h>, <sys/types.h>, the System Interfaces volume of
211 IEEE Std 1003.1-2001, clearerr(), ctermid(), fclose(), fdopen(),
212 fgetc(), fgetpos(), ferror(), feof(), fflush(), fgets(), fileno(),
213 flockfile(), fopen(), fputc(), fputs(), fread(), freopen(), fseek(),
214 fsetpos(), ftell(), fwrite(), getc(), getc_unlocked(), getwchar(),
215 getchar(), getopt(), gets(), pclose(), perror(), popen(), printf(),
216 putc(), putchar(), puts(), putwchar(), remove(), rename(), rewind(),
217 scanf(), setbuf(), setvbuf(), sscanf(), stdin, system(), tempnam(),
218 tmpfile(), tmpnam(), ungetc(), vfscanf(), vscanf(), vprintf(), vss‐
219 canf()
220
222 Portions of this text are reprinted and reproduced in electronic form
223 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
224 -- Portable Operating System Interface (POSIX), The Open Group Base
225 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
226 Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/online.html .
231
232
233
234IEEE/The Open Group 2003 <stdio.h>(0P)