We have:
std::string string_array[2];
string_array[0] = "some data";
string_array[1] = "some more data";
char* cstring_array[2];
What is the most efficient way to copy data from string_array to cstring_array? Or pass string_array to the function, needed “const char* cstring_array[]“?
A function that takes a
char const *is only written to accept a single string at a time, not an array of strings. To pass anstd::stringto such a function, just call the function withyour_string.c_str()as the parameter.Edit: for a function that takes an array of strings, the obvious choice (at least to me) would be to write a minimal front-end that lets you pass a
vector<std::string>: