cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : istringstream : rdbuf
- -
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
istringstream
· istringstream::istrings...
member functions:
· istringstream::rdbuf
· istringstream::str

-

istringstream::rdbuf public member function
stringbuf* rdbuf ( ) const;

Get/set the associated stringbuf object

Returns a pointer to the stringbuf object associated with the stream.

Parameters

none

Return Value

A pointer to the stringbuf object associated with the stream.
Notice that for any successfully constructed istringstream object this pointer is never NULL, even if the buffer string is empty.

Example

// istringstream::rdbuf
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main () {
  stringbuf *pbuf;
  istringstream iss;
  string mystr ("This is a sample string");

  iss.str (mystr);

  pbuf=iss.rdbuf();

  int size = pbuf->in_avail();

  for (int n=0; n<size; n++)
    cout << (char) pbuf->sbumpc();

  return 0;
}

This is an elaborate way to print out a string by using the string stream buffer members.

Basic template member declaration

( basic_istringstream<charT,traits,Allocator> )
basic_stringbuf<charT,traits,Allocator> * rdbuf () const;

See also

ios::rdbuf Get/set the associated stream buffer (public member function)
stringbuf String stream buffer (class)

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