I'm seeing that he keeps pushing back the address of thisString which, when the function exits, is undefined and likely trashed at some point. I'd traverse the original string and push back the address of the pointer, beginning with the first char, at each byte following the divider while replacing the divider by '/0'. Or do the same thing using, as Benjamin suggested, strtok().
Maybe something close to
void explode(vector<char*>* storage, char* string, char divider)
{
char *p = string; // working pointer
storage->push_back(p); // store the beginning of the string
while (*p) { // track each char in string until the nul terminator
if (*p == divider) { // p points to divider?
*p++ = '\0'; // mark the end of the sub-string
// push back the address of the next byte if it isn't
// the end of the input string
if (*p) storage->push_back (p);
}
else p++; // advance the pointer
}
}
Edit: This all depends on the original string remaining intact.
Edit 2: strtok might work faster if it's guaranteed that a divider doesn't exist at the very end of the string or you don't mind an empty string.
Lilith, Night Butterfly
I'm not a programmer but I play one in the office