V7M/man/man3/fopen.3s

.TH FOPEN 3S 
.SH NAME
fopen, freopen, fdopen \- open a stream
.SH SYNOPSIS
.B #include <stdio.h>
.PP
.SM
.B FILE
.B *fopen(filename, type)
.br
.B char *filename, *type;
.PP
.SM
.B FILE
.B *freopen(filename, type, stream)
.br
.B char *filename, *type;
.br
.SM
.B FILE
.B *stream;
.PP
.SM
.B FILE
.B *fdopen(fildes, type)
.br
.B char *type;
.SH DESCRIPTION
.I Fopen
opens the file named by
.I filename
and associates a stream with it.
.I Fopen
returns a pointer to be used to identify
the stream in subsequent operations.
.PP
.I Type
is a character string having one of the following values:
.TP 5
"r"
open for reading
.ns
.TP 5
"w"
create for writing
.ns
.TP 5
"a"
append: open for writing at end
of file, or create for writing
.PP
.I Freopen
substitutes the named file in place
of the open
.IR stream .
It returns the original value of
.IR stream .
The original stream is closed.
.PP
.I Freopen
is typically used to attach the preopened
constant names,
.B stdin, stdout, stderr,
to specified files.
.PP
.I Fdopen
associates a stream with a file descriptor obtained from
.I open, dup, creat,
or
.IR pipe (2).
The
.I type
of the stream must agree with the mode of the open file.
.SH "SEE ALSO"
open(2),
fclose(3)
.SH DIAGNOSTICS
.I Fopen
and 
.I freopen
return the pointer
.SM
.B NULL
if
.I filename
cannot be accessed.
.SH BUGS
.I Fdopen
is not portable to systems other than UNIX.