Is there any better way to convert vector of string to the vector of chars with zero terminator between strings.
So if I have a vector with the following strings "test","my","string"
, then I want to receive one vector of chars: "test\0my\0string\0"
.
At this moment this code works fine, but is there any better (more beautiful) solution?
std::vector<std::string> string_array = {"test", "my", "string"};
std::vector<char> buffer_temp;
for (auto &str : string_array)
{
for (auto &chr : str)
{
buffer_temp.push_back(chr);
}
buffer_temp.push_back('\0');
}