| r | Open for reading (existing file only) |
| rb | Open for reading (existing file only) in binary mode |
| rt | Open for reading (existing file only) in text mode |
| r+ | Open for update
(existing file only) |
| rb+ | Open for update
(existing file only) in binary mode |
| rt+ | Open for update
(existing file only) in text mode |
| w | Open (or create) for writing (and delete any previous data) |
| wb | Open (or create) for writing
(and delete any previous data) in binary mode |
| wt | Open (or create) for writing
(and delete any previous data) in text mode |
| w+ | Open (or create) for update
(and delete any previous data) |
| wb+ | Open (or create) for update
(and delete any previous data) in binary mode |
| wt+ | Open (or create) for update
(and delete any previous data) in text mode |
| a | Open (or create) for append
(and keep any previous data) |
| ab | Open (or create) for append
(and keep any previous data) in binary mode |
| at | Open (or create) for append
(and keep any previous data) in text mode |
| a+ | Open (or create) for append update
(and keep any previous data) |
| ab+ | Open (or create) for append update
(and keep any previous data) in binary mode |
| at+ | Open (or create) for append update
(and keep any previous data) in text mode |
| Notes: |
- In binary mode (b), data values (including CR, LF, and EOF)
are passed without translation.
- In text mode (t), with DOS:
- A CR/LF pair from the file is translated to '\n' by a read.
- A '\n' is translated to a CR/LF pair into the file by a write.
- An EOF byte from the file is not passed as data by a read; instead it sets
the EOF flag.
- If neither binary or text mode is specified, the mode is determined by the value
of the global variable _fmode.
- If _fmode is equal to O_BINARY,
the default mode for fopen is binary.
- If _fmode is equal to O_TEXT,
the default mode for fopen is text.
|