cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : stringbuf : str
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
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

// 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::stringbuf Construct a string stream buffer object (constructor member)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us