fopen, freopen, fdopen - open a stream
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<s
\bst
\btd
\bdi
\bio
\bo.
\b.h
\bh>
\b>
F
\bFI
\bIL
\bLE
\bE *
\b*f
\bfo
\bop
\bpe
\ben
\bn(
\b(f
\bfi
\bil
\ble
\ben
\bna
\bam
\bme
\be,
\b, t
\bty
\byp
\bpe
\be)
\b)
c
\bch
\bha
\bar
\br *
\b*f
\bfi
\bil
\ble
\ben
\bna
\bam
\bme
\be,
\b, *
\b*t
\bty
\byp
\bpe
\be;
\b;
F
\bFI
\bIL
\bLE
\bE *
\b*f
\bfr
\bre
\beo
\bop
\bpe
\ben
\bn(
\b(f
\bfi
\bil
\ble
\ben
\bna
\bam
\bme
\be,
\b, t
\bty
\byp
\bpe
\be,
\b, s
\bst
\btr
\bre
\bea
\bam
\bm)
\b)
c
\bch
\bha
\bar
\br *
\b*f
\bfi
\bil
\ble
\ben
\bna
\bam
\bme
\be,
\b, *
\b*t
\bty
\byp
\bpe
\be;
\b;
F
\bFI
\bIL
\bLE
\bE *
\b*s
\bst
\btr
\bre
\bea
\bam
\bm;
\b;
F
\bFI
\bIL
\bLE
\bE *
\b*f
\bfd
\bdo
\bop
\bpe
\ben
\bn(
\b(f
\bfi
\bil
\bld
\bde
\bes
\bs,
\b, t
\bty
\byp
\bpe
\be)
\b)
c
\bch
\bha
\bar
\br *
\b*t
\bty
\byp
\bpe
\be;
\b;
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
_
\bF_
\bo_
\bp_
\be_
\bn opens the file named by _
\bf_
\bi_
\bl_
\be_
\bn_
\ba_
\bm_
\be and associates a
stream with it. _
\bF_
\bo_
\bp_
\be_
\bn returns a pointer to be used to iden-
tify the stream in subsequent operations.
_
\bT_
\by_
\bp_
\be is a character string having one of the following
"a" append: open for writing at end of file, or create for
In addition, each _
\bt_
\by_
\bp_
\be 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 trun-
cates it, and "a+" positions it at the end. Both reads and
writes may be used on read/write streams, with the limita-
tion that an _
\bf_
\bs_
\be_
\be_
\bk, _
\br_
\be_
\bw_
\bi_
\bn_
\bd, or reading an end-of-file must
be used between a read and a write or vice-versa.
_
\bF_
\br_
\be_
\bo_
\bp_
\be_
\bn substitutes the named file in place of the open
_
\bs_
\bt_
\br_
\be_
\ba_
\bm. It returns the original value of _
\bs_
\bt_
\br_
\be_
\ba_
\bm. The ori-
_
\bF_
\br_
\be_
\bo_
\bp_
\be_
\bn is typically used to attach the preopened constant
names, s
\bst
\btd
\bdi
\bin
\bn,
\b, s
\bst
\btd
\bdo
\bou
\but
\bt,
\b, s
\bst
\btd
\bde
\ber
\brr
\br,
\b, to specified files.
_
\bF_
\bd_
\bo_
\bp_
\be_
\bn associates a stream with a file descriptor obtained
from _
\bo_
\bp_
\be_
\bn, _
\bd_
\bu_
\bp, _
\bc_
\br_
\be_
\ba_
\bt, or _
\bp_
\bi_
\bp_
\be(2). The _
\bt_
\by_
\bp_
\be of the stream
must agree with the mode of the open file.
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
D
\bDI
\bIA
\bAG
\bGN
\bNO
\bOS
\bST
\bTI
\bIC
\bCS
\bS
_
\bF_
\bo_
\bp_
\be_
\bn and _
\bf_
\br_
\be_
\bo_
\bp_
\be_
\bn return the pointer N
\bNU
\bUL
\bLL
\bL if _
\bf_
\bi_
\bl_
\be_
\bn_
\ba_
\bm_
\be cannot
be accessed, if too many files are already open, or if other
resources needed cannot be allocated.
_
\bF_
\bd_
\bo_
\bp_
\be_
\bn is not portable to systems other than UNIX.
The read/write _
\bt_
\by_
\bp_
\be_
\bs do not exist on all systems. Those
systems without read/write modes will probably treat the
_
\bt_
\by_
\bp_
\be as if the "+" was not present. These are unreliable in
In order to support the same number of open files as does
the system, _
\bf_
\bo_
\bp_
\be_
\bn must allocate additional memory for data
structures using _
\bc_
\ba_
\bl_
\bl_
\bo_
\bc after 20 files have been opened.
This confuses some programs which use their own memory allo-
cators. An undocumented routine, _
\bf__
\bp_
\br_
\be_
\ba_
\bl_
\bl_
\bo_
\bc, may be called
to force immediate allocation of all internal memory except