>>and put it into a std::string?
That's the tricky part. Well, off the top of my head, you could do it like this:
Code:
std::vector<char> strBytes(size + 1, '\0');
std::copy(data.begin() + offset, data.begin() + offset + size, strBytes.begin());
std::string str(&(strBytes[0]));
offset is the position in the data buffer that the string is located at, and size is the length of the string.
**EDIT**
If you prefer the C way:
Code:
std::vector<char> strBytes(size + 1, '\0');
memcpy(&(strBytes[0]), &(data[0]), size);
std::string str = strBytes;