Is this the buffer? I/O stream question.

I am really trying to understand what the buffers are for I/O streams. So far as I know, when you move data through streams, the data stacks in the buffer and is then written/read all at once or in small pieces for efficiency and to make the data stream more smooth.

When I use the istream and ostream functions, is it the buffer than I put data into and read from? For example:

Let's say that I use the cin.putback()-n cin.get() and cout operator<< functions.
When I use there, is it the buffer that I write to / read from directly in each stream or is the buffer somewhere else, being handled by the program indirectly?
Last edited on
the stream object only presents the interface (operator>>, operator<<, etc), and whatever's necessary to support it (I/O manipulator flags, error bits, etc)

the buffer is "somewhere else": it is inside the associated streambuf object, pointer to which you can get from your stream by calling rdbuf().

streambuf decides (or can be told) when to flush your output and when to pull in more data from the "outside" (if ever: stringstream's streambuf doesn't have an "outside")
Topic archived. No new replies allowed.