iostream hierarchy istringstream:: rdbuf |
cplusplus.com |
Get the stringbuf object associated with the stream.
Returns the stringbuf object associated with the stream.
Parameters.
Return Value.
A pointer to the stringbuf object associated with the stream.
Notice that this pointer is never NULL, even if the buffer is not associated with any string object.
It is a pointer to the private stringbuf object.
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. Just for demonstrative purposes
on how to use rdbuf.
Basic template member declaration ( basic_istringstream<charT,traits,Allocator> ):
basic_stringbuf<charT,traits,Allocator> * rdbuf () const; |
See also.
ios::rdbuf
stringbuf class,
istringstream class