i am reading in a binary file via the usual c++/STL/iostream syntax. i am copying the whole content into an dynamically allocated char array and this works fine so far.
but since i want to serve parts of the content as lines to another part of the program, i think it would be better/easier to stick to streams because i don't want to hack around with cstring functions and pointers.
my question now is, how can i store the read in memory. in a stringstream? or in a string? which fits better? are there any advantages or disadvantages of one over the other?
thanks in advance!
If you want to read from it as a stream, you might as well read directly from the file to the stringstream:
std::stringstream data; data << input_file.rdbuf();
That reads the entire contents of 'input_file' into 'data'. You can read the data from there like you would any other stream.