I have seen in a couple of places that strstream objects are deprecated, but there are also stringstream objects. My compiler has 2 headers <strstream> and <sstream> and I don't know which is which. In light of this, which header should I use to produce more modern code?

I suspect <sstream> is the correct one because if I pull them up side-by-side I can find templates and definitions for various "stringstream" classes in it, but not in <strstream>.

Any insight would be much appreciated.

Well MSDN says this:

The classes in <strstream> are deprecated. Consider using the classes in <sstream> instead.

And www.cplusplus.com has no mention of strstream at all, it seems to have vanished from their standard library reference documents.

It appears also that strstream uses char arrays in the underlying implementation while stringstream uses std::string, which is better, of course.

Thanks mike.

I started on cplusplus.com and I found links for both headers on the main reference page, but they both linked to the iostream page so that wasn't much help. A search will yield a stringstream page, but doesn't give the header name.

This page. has stringstream and strstream sections and mentions that "strstream classes are deprecated", but it doesn't give the header names.

edit:
Looking closer at some of the pages and diagrams on cplusplus.com, I've been able to find obscure references to <sstream> for anything stringstream-related. Thanks again.

>>. A search will yield a stringstream page, but doesn't give the header name.

What you do then is click on the constructor of the object( in that page ), and it will show you
a full code, using the object at interest.

>>. A search will yield a stringstream page, but doesn't give the header name.

What you do then is click on the constructor of the object( in that page ), and it will show you
a full code, using the object at interest.

Wow, now I really feel stupid... Worst part is I knew that too, just forgot... :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.