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) |