14.6 FILE OPENING MODES

If we want to open a file, Operating system wants to know the exact way in which the file should respond to various commands (functions). For this purpose, compiler specifies various file opening modes. Table 14.1 summarizes the various modes supported by C++.

 

Table 14.1 File Modes

Sr. No Open mode Description
1 in Open for reading
2 out Open for writing
3 ate Seek to end of file upon original open
4 app Append mode
5 trunc Truncate file if already exists
6 nocreate Open fails if file does not exists
7 noreplace Open fails if file already exists
8 binary Opens file as binary

The detalied explanation of file modes is as follows.

  1. (in) This mode should be specified for input files.
  2. (out) This mode ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.