for some reason I cannot explain, every single item in the character array...is equal to the last item added to it...for example progArgs[0] through progArgs[size] contains the
You're setting progArgs[count]
to the same item every time!
int count = 0;
char *progArgs[commandList.size()]
for(list::iterator t=commandList.begin(); t!=commandList.end(); t++)
{
char * item = new char[strlen((*t).c_str()) + 1]; //create new character string
strcpy(item, (*t).c_str()); //convert from const char to char
progArgs[count] = item;
count++;
}
Then remember to call delete[]
for each element in progArgs.
Personally, I'd create an array of string
and convert to char *
on the fly as needed.