Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
a, r, w
◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Constant: a, a+, r, r+, w, w+
Include: <stdio.h>
Context: fdopen, fopen, freopen, _fsopen
Synopsis: Specifies the type of access (a, r, or w) requested for
the file. The mode of translation (b or t) can be specified
along with the type of access.
The access types are described below:
Type Description
"a" Opens for writing at the end of the file (appending);
creates the file first if it does not exist. All write
operations occur at the end of the file. Although the
file pointer can be repositioned using fseek or rewind,
it is always moved back to the end of the file before
any write operation is carried out.
"a+" Same as above, but also allows reading.
"r" Opens for reading. If the file does not exist or cannot
be found, the open call will fail.
"r+" Opens for both reading and writing. If the file does not
exist, or cannot be found, the open call will fail.
"w" Opens an empty file for writing. If the given file
exists, its contents are destroyed.
"w+" Opens an empty file for both reading and writing. If the
given file exists, its contents are destroyed.
When the "r+", "w+", or "a+" type is specified, both reading and
writing are allowed (the file is said to be open for "update").
However, when switching between reading and writing, you must
reposition the file pointer, using fsetpos, fseek, or rewind.
You can specify the current position, if desired.