.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)fopen.3 6.1 (Berkeley) %G%
fopen, freopen, fdopen \- open a stream
.B *fopen(filename, type)
.B char *filename, *type;
.B *freopen(filename, type, stream)
.B char *filename, *type;
and associates a stream with it.
returns a pointer to be used to identify the stream in subsequent operations.
is a character string having one of the following values:
append: open for writing at end of file, or create for writing
may be followed by a '+' to have the file opened for reading and writing.
"r+" positions the stream at the beginning of the file, "w+" creates
or truncates it, and "a+" positions it at the end. Both reads and writes
may be used on read/write streams, with the limitation that an
or reading an end-of-file must be used between a read and a write or vice-versa.
substitutes the named file in place of the open
It returns the original value of
The original stream is closed.
is typically used to attach the preopened constant names,
.B stdin, stdout, stderr,
associates a stream with a file descriptor obtained from
of the stream must agree with the mode of the open file.
is not portable to systems other than UNIX.
do not exist on all systems. Those systems without
read/write modes will probably treat the
as if the '+' was not present. These are unreliable in any event.