File I/O
suggest changeC++ file I/O is done via streams. The key abstractions are:
std::istream for input.
std::ostream for output.
std::streambuf for the underlying character sequence.
Formatted input uses operator>>.
Formatted output uses operator<<.
Streams use std::locale, e.g., for details of the formatting and for translation between external encodings and the internal encoding.
More on streams.
Reading text file into a std::string
Writing files with non-standard locale settings
Checking end of file inside a loop condition is bad practice
Reading a file into a container
Reading a struct from a formatted text file
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents