.\" Copyright (c) 1990, 1991 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" Chris Torek and the American National Standards Committee X3,
.\" on Information Processing Systems.
.\" %sccs.include.redist.man%
.\" @(#)fopen.3 6.8 (Berkeley) %G%
.Nd stream open functions
.Fn fopen "char *path" "char *mode"
.Fn fdopen "int fildes" "char *mode"
.Fn freopen "char *path" "char *mode" "FILE *stream"
opens the file whose name is the string pointed to by
and associates a stream with it.
points to a string beginning with one of the following
sequences (Additional characters may follow these sequences.):
Open text file for reading.
The stream is positioned at the beginning of the file.
Open for reading and writing.
The stream is positioned at the beginning of the file.
Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
Open for reading and writing.
The file is created if it does not exist, otherwise it is truncated.
The stream is positioned at the beginning of the file.
The file is created if it does not exist.
The stream is positioned at the end of the file.
Open for reading and writing.
The file is created if it does not exist.
The stream is positioned at the end of the file.
string can also include the letter ``b'' either as a third character or
as a character between the characters in any of the two-character strings
This is strictly for compatibility with
and has no effect; the ``b'' is ignored.
Any created files will have mode
as modified by the process'
Reads and writes may be intermixed on read/write streams in any order,
and do not require an intermediate seek as in previous versions of
This is not portable to other systems, however;
a file positioning function intervene between output and input, unless
an input operation encounters end-of-file.
function associates a stream with the existing file descriptor,
of the stream must be compatible with the mode of the file descriptor.
opens the file whose name is the string pointed to by
and associates the stream pointed to by
The original stream (if it exists) is closed.
argument is used just as in the
is to change the file associated with a
Upon successful completion
is returned and the global variable
is set to indicate the error.
for any of the errors specified for the routine
for any of the errors specified for the routine
for any of the errors specified for the routine
for any of the errors specified for the routines