fstream
fstream is a component of the C++ standard library that provides file input and output streams. It is defined in the <fstream> header and is based on the generic iostreams framework. The library supplies three types: std::ifstream for input from files, std::ofstream for output to files, and std::fstream for both input and output from files. These types are aliases of the templated std::basic_fstream<char> specialized for char.
Opening files: A file stream is opened by constructing it with a filename and an opening mode,
Reading and writing: Data are transferred using the extraction operator (>>) and insertion operator (<<), as well as
Error handling and text vs binary: Streams maintain state flags such as goodbit, eofbit, failbit, and badbit.
Use in practice: fstream is widely used for reading and writing configuration files, logs, and data interchange.
---