ostringstream::str
string str ( ) const; void str ( string & s ); | ostringstream |
cplusplus.com |
Get/set the associated string object.
The first syntax returns a copy of the string object currently associated with the
internal buffer.
The second syntax sets a new value for the string object associated with
the buffer.
The buffer of a stringstream is usually associated with an STL
string object.
Parameters.
Return Value.
The second syntax returns a copy of the string object
currently associated with the stream's buffer.
Example.
// ostringstream::str
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main () {
ostringstream oss;
string mystr;
oss << "Sample string";
mystr=oss.str();
cout << mystr;
return 0;
}
Basic template member declaration ( basic_ostringstream<charT,traits,Allocator> ):
basic_string<charT,traits,Allocator> str () const; void str (const basic_string<charT,traits,Allocator> & s ); |
See also.
(constructor)
ostringstream class