I tried to mend the code, but seriously, it is beyond repair.
I suggest you do it again using std::vector and std::string. Here's a splitter function.
Code:
#include <vector>
#include <string>
using std::vector;
using std::string;
// this takes a string and splits it into an array of smaller strings
// it's splitted every time split_at is encountered
void split_string(const string &s, vector<string> & out, char split_at)
{
// for searching the string
string::const_iterator stay, run;
// set stay to the start of the string
stay = s.begin();
// temporary
string t;
// loop run through the string, from front to back
for(run=stay; run != s.end(); ++run)
{
// if encountered split char...
if(*run == split_at)
{
// ...clear the temporary value...
t.erase();
// (speeds it up a little)
t.reserve(run-stay);
// ..., copy current substring to temporary...
t.append(stay, run);
// ...and add it to the array.
out.push_back(t);
// Finally, let the next substring begin directly after the splitting char.
stay = run+1;
}
}
// same as above for the last piece (from last split char to end of string)
t.erase();
t.reserve(run-stay);
t.append(stay, run);
out.push_back(t);
}
Alternativly, grab boost::string_tokenizer from www.boost.org