1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)fopen.3s 6.3 (Berkeley) 5/27/86
7 .TH FOPEN 3 "May 27, 1986"
10 fopen, freopen, fdopen \- open a stream
16 FILE *fopen(const char *\fIfilename\fP, const char *\fItype\fP)
17 FILE *freopen(const char *\fIfilename\fP, const char *\fItype\fP, FILE *\fIstream\fP)
18 FILE *fdopen(int \fIfildes\fP, const char *\fItype\fP)
23 opens the file named by
25 and associates a stream with it.
27 returns a pointer to be used to identify the stream in subsequent operations.
30 is a character string having one of the following values:
41 append: open for writing at end of file, or create for writing
45 may be followed by a "+" to have the file opened for reading and writing.
46 "r+" positions the stream at the beginning of the file, "w+" creates
47 or truncates it, and "a+" positions it at the end. Both reads and writes
48 may be used on read/write streams, with the limitation that an
51 or reading an end-of-file must be used between a read and a write or vice-versa.
54 substitutes the named file in place of the open
56 It returns the original value of
58 The original stream is closed.
61 is typically used to attach the preopened constant names,
62 .B stdin, stdout, stderr,
66 associates a stream with a file descriptor obtained from
74 of the stream must agree with the mode of the open file.
88 if too many files are already open,
89 or if other resources needed cannot be allocated.
92 is not portable to systems other than UNIX.
96 do not exist on all systems. Those systems without
97 read/write modes will probably treat the
99 as if the "+" was not present. These are unreliable in any event.