I made an adapter function to convert a const char * to char ** splitting the words in the initial string at each white space (leading, consecutive and trailing white spaces should be ignored).#include <iostream>#include <vector>#include <cctype>void str2arg(const char * str, std::vector<char*> & arg, std::string & memory) {  arg.clear();  memory.clear();  bool copied_first_char = false;  for ( size_t i = 0; str[i]!='\0'; ++i) {    if (isspace(str[i])) {      if (copied_first_char) {        if (!isspace(str[i+1])) {          memory += '\0';        }      }    } else {      copied_first_char = true;      memory += str[i];    }  }  if (memory.back()!='\0') memory += '\0';   //from now on, memory should't be touched!  for ( size_t i = 0; i < memory.length(); ++i ) {    if (i==0 or memory[i-1]=='\0') arg.push_back(&memory[i]);  }}int main() {  std::vector<char*> av;  std::string m;  str2arg(   this is  a test   string   , av, m);  std::cout << argc= << av.size() <<   argv= << av.data() << std::endl;  for (auto i: av) std::cout << i << .\n;  return 0;}Basically the function takes the original C-string, a std::vector that will hold the pointers to the words, and a std::string for automated memory management.In the first part of str2arg() I copy the chars from the original string substituting white spaces with the termination char '\0'. Then I push the char* into the vector looking at the positions of '\0'.Of course both the vector and the string passed to str2arg() must then be used as read-only variables.This looks fair, but I'm not totally proud of it...
Function to convert from const char * to char**
c++;strings;c++11