Up until now, we have opened the file using the default mode. There are two modes that may be used to open a file:
- std::ios::in: Opens the file for reading
- std::ios::out: Opens the file for writing
In addition, there are several other modes that may be used in conjunction with these two, to modify how a file is opened:
- std::ios::binary: Opens the file for binary use. By default, std::fstream is in text mode, which applies specific rules about how a file is formatted using newline characters, and which types of character may be read/written to a file. These rules are usually appropriate for text files, but cause problems when you attempt to read/write binary data to a file. In this case, std::ios::binary should ...