I need to call the getList function below which comes from a library I cannot change.
#include <iostream>
#include <vector>
#include <string>
//function already exists in a separate library, can't be changed
void getList(const char* list[], int count){};
int main()
{
std::vector<std::string> vectorOfStrings = {"123" , "abc", "def", "456"};
//call getList and pass vectorOfStrings and vectorOfStrings.size()
getList(/*convert std::vector<std::string> to const char** */, vectorOfStrings.size());
return 0;
}
I already asked a similar question here and got an answer but I thought there might be a C++ way of doing this.