How to initialize a string stream from a char vector

I am currently using boost char array

boost::array<char, 512> received_data; std::istringstream ss_(received_data.data()); 

but what if my received_data was std::vector<char> received_data(512);

How could I get this data in my std::istringstream ss_ ?

+4
source share
2 answers

The istringstream string takes a string, and the string can be made of two char iterators, for example:

 istringstream iss(string(v.begin(), v.end()); 
+5
source
 std::vector<char> receivedData(512); std::istringstream iss(&receivedData[0]); 
+2
source

Source: https://habr.com/ru/post/1482723/


All Articles