strstream

#include <strstrea.h>

The strstream class supports I/O streams that have character arrays as a source and destination. You can allocate a character array prior to construction, or the constructor can internally allocate a dynamic array. You can then use all the input and output stream operators and functions to fill the array.

Be aware that a put pointer and a get pointer are working independently behind the scenes in the attached strstreambuf class. The put pointer advances as you insert fields into the stream’s array, and the get pointer advances as you extract fields. The ostream::seekp function moves the put pointer, and the istream::seekg function moves the get pointer. If either pointer reaches the end of the string (and sets the ios::eof flag), you must call clear before seeking.

Construction/Destruction — Public Members

strstream

Constructs a strstream object.

~strstream

Destroys a strstream object.

Other Functions — Public Members

pcount

Returns the number of bytes that have been stored in the stream’s buffer.

rdbuf

Returns a pointer to the stream’s associated strstreambuf object.

str

Returns a pointer to the string stream’s character buffer and freezes it.

Input/Output Stream Classes

See Also   strstreambuf, streambuf, istrstream, ostrstream