I have a the following code in a for loop. I am trying to copy a string into a char**. However, when I run the below code, I never get to the "HERE" portion of my code. Instead, the next iteration of the for loop is executed. Can anyone explain this behavior?
string str = "ls -1";
string cmd = "ls";
char** command;
command = new char*[str.size()+1];
strncat(*command, str.c_str(), str.size+1);
cout << "HERE\n";
*command = strtok(*command, " ");
execvp(cmd.c_str(), command);
EDIT:
I am using a char** to fit the parameters of execvp, and to use strtok to separate on spaces.