Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
stringbuf
stringbuf::stringbuf
public members:
stringbuf::str
virtual members:
stringbuf::overflow
stringbuf::pbackfail
stringbuf::seekoff
stringbuf::seekpos
stringbuf::setbuf
stringbuf::underflow


stringbuf::str

public member function
string str ( ) const;
void str ( const string & s );

Get/set the string content

The first version returns a string object with a copy of the content in the internal character sequence.

The second version sets a copy of parameter s as the new internal character sequence and intializes the input and output sequences according to the mode used when the object was created.

Parameters

s
Standard string object whose content is to be copied into the internal character sequence.

Return Value

The second syntax returns a string object with a copy of the content in the internal character sequence.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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> )
1
2
basic_string<charT,traits,Allocator> str () const;
void str (const basic_string<charT,traits,Allocator> & s );


See also