FREOPEN(3) NEWLIB FREOPEN(3)NAME
4.25 `freopen'--open a file using an existing file descriptor
SYNOPSIS
#include <stdio.h>
FILE *freopen(const char *FILE, const char *MODE,
FILE *FP);
FILE *_freopen_r(struct _reent *PTR, const char *FILE,
const char *MODE, FILE *FP);
DESCRIPTION
Use this variant of `fopen' if you wish to specify a particular file
descriptor FP (notably `stdin', `stdout', or `stderr') for the file.
If FP was associated with another file or stream, `freopen' closes
that other file or stream (but ignores any errors while closing it).
FILE and MODE are used just as in `fopen'.
If FILE is `NULL', the underlying stream is modified rather than
closed. The file cannot be given a more permissive access mode (for
example, a MODE of "w" will fail on a read-only file descriptor), but
can change status such as append or binary mode. If modification is
not possible, failure occurs.
RETURNS
If successful, the result is the same as the argument FP. If the file
cannot be opened as specified, the result is `NULL'.
PORTABILITY
ANSI C requires `freopen'.
Supporting OS subroutines required: `close', `fstat', `isatty',
`lseek', `open', `read', `sbrk', `write'.
SEE ALSO
freopen is part of the library. The full documentation for is main‐
tained as a Texinfo manual. If info and are properly installed at your
site, the command
info
will give you access to the complete manual.
NEWLIB April 2010 FREOPEN(3)