We All stream for strstream

Now it's time to get back to our discussion of strstream. A strstream (short for string stream) allows us to write data to its buffer and then read the resulting data back into a variable. An example is the program shown in Figure 9.20, which uses a strstream object to combine a year, month, and day number to make one string containing all of those values.

Figure 9.20. A strstream formatting example (code\stream2.cc)

A strstream is very similar to an ostream, except that once we have written data to a strstream, we can read it from the strstream into a variable just as though we were reading from a file or the keyboard. ...

Get Learning to Program in C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.