I'm looking for a way to call execvp() in a C++ program that uses string arrays. So if, for example, I have an array of strings,
s[0] = "ls";
s[1] = "-l";
then, s[i].c_str() converts it to const char*. However, I need s[i] converted to a char* const to pass it to execvp(). Is there any way to do this in C++?
const_castdoesn't work forconst char*tochar* const. How will making copies of the string help?