stringbuf::str
string str ( ) const; void str ( string & s ); | stringbuf |
cplusplus.com |
Get/set the string content.
The first syntax returns a copy of the string content of the
internal character sequence.
The second syntax sets a copy of parameter s as the new internal character
sequence (string).
Parameters.
Return Value.
The second syntax returns an STL string
object with a copy of the string content currently stored in the streambuf.
Example.
// stringbuf::str
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main () {
stringbuf sb;
string mystr;
sb.sputn ("Sample string",13);
mystr=sb.str();
cout << mystr;
return 0;
}
Basic template member declaration ( basic_stringbuf<charT,traits,Allocator> ):
basic_string<charT,traits,Allocator> str () const; void str (const basic_string<charT,traits,Allocator> & s ); |
See also.
stringbuf class