I have a char* and the data length that I’m receiving from a library, and I need to pass the data to a function that takes an istream.
I know I can create a stringstream but that will copy all the data. And also, the data will surely have 0s since it’s a zip file, and creating a stringstream will take the data until the first 0 I think.
Is there any way to create an istream from a char* and it’s size without copying all the data?
Here’s a non-deprecated method found on the web, has you derive your own
std::streambufclass, but easy and seems to work:Which outputs: