Constructing a Portable ASCII Virtual Stream for Output
Example 7 shows how to construct a portable ASCII virtual stream for output using an RWPortalStreambuf.
Example 7 – Constructing a portable ASCII virtual stream for output
RWPortalStreambuf buf(portal);
RWpostream ostrm(&buf);
The streambuf object buf must remain in scope as long as the output stream is being used because the output stream keeps a pointer to the streambuf. If buf goes out of scope, the pointer in the output stream becomes invalid, and when the stream attempts to write bytes, the application will fail.