std::strstream::str (3) - Linux Manuals
std::strstream::str: std::strstream::str
NAME
std::strstream::str - std::strstream::str
Synopsis
char* str();
Returns the pointer to the beginning of the buffer, after freezing it. Effectively calls rdbuf()->str()
Notes
Before a call to str() that uses the result as a C string, the stream buffer must be null-terminated. Regular output such as with stream << 1.2 does not store a null terminator, it must be appended explicitly, typically with the manipulator std::ends.
After a call to str(), dynamic streams become frozen. A call to freeze(false) is required before exiting the scope in which this strstream object was created. otherwise the destructor will leak memory. Also, additional output to a frozen stream may be truncated once it reaches the end of the allocated buffer, which may leave the buffer not null-terminated.
Parameters
(none)
Return value
Pointer to the beginning of the buffer in the associated std::strsteambuf or NULL if no buffer is available.
Example
// Run this code
Possible output:
See also
str (public member function of std::strstreambuf)