Please help me to understand the difference between streambuf, stringbuf and stringstream?

Viewed 10792

Please someone help me to undersatnd the difference between " streambuf, stringbuf and stringstream".

void f1(std::string const& text)
{
     std::stringstream           inStream(text);
    cout<<inStream.str()<<endl;
 }

or if I write

void f2(std::string const& text)
{
    std::stringbuf           inStream(text);
    cout<<inStream.str()<<endl;
 }

Both shows the same result. When should I use stringbuf or stringstream? Thanks in advance.

4 Answers
Related