C++ IOStreams

use examples for streams

Fig 1. IOStreams Classes

1.0 Concept

The std::iostream libraries provide stream interfaces for reading and writing to the console, files, and stringstreams. The iostream class hierarchy is rooted at std::ios, a class for managing formats, error states, and stream buffers.
std::streambuf connects a C++ program with the console, std::filebuf connects to files, and std::stringbuf connects to in-memory strings through a stream interface.
std::istream, std::ifstream, and std::istringstream provide interfaces for programs to use ios and read from filebufs in a simple way. Similarly, std::ostream, std::ofstream, and std::ostringstream provide an interface to use ios and write to filebufs.
These classes do not provide any virtual functions, but if you need to modify a stream's behaviour you can do that by overriding virtual functions in the streambuf classes.

2.0 Contents

This repository contains demonstration codes that illustrate:
  • Formats
    Formatting stream outputs.
  • Fileio
    Typical file input-output operations.
  • Filebuf
    Programming filebufs for the same kind of input-output operations.
  • StringIO
    Typical usage for stringstreams.
  • ReadWrite
    Setting up a stream for both read and write operations.

3.0 Build

IOStreams code was built with Visual Studio Community Edition - 2019 and tested on Windows 10.

4.0 Resources

iostreams.pdf
Quick description of the std::iostream hierarchy.
iostreamsRef.pdf
Complete description of the interfaces for ios and each of the iostream, and streambuf classes