devxlogo

Using strstream for ‘incore’ binary I/O

Question:
Can I use strstream functions for incode I/O,i.e. writing to memory just as if it were binaryinput/output to a file?

Answer:
You can use it to do incode input and output but there is no way to make it behave like a binary store, i.e.:

strstream s;s << 123;const char * c = s.str (); // c will have "123" and not a binary rep.
The only way to do what you want is to write your own classthat mimics strstream and writes data as binary.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.