Troi oi...
Here, I just wrote this real quick. Maybe it'll work...
Code:
const char* pipeTokenize(const char *str, char *tokenized, int bufSize) {
*tokenized = NULL;
int size = 0;
while (*str != NULL && size < bufSize) {
if (*str == '|') {
++str;
break;
}
++size;
*tokenized = *str;
*++tokenized = NULL;
++str;
}
return *str == NULL ? NULL : str;
}
int main() {
string delimited = "|field2||field4";
char buffer[256];
const char *p = delimited.c_str();
while (p != NULL) {
p = pipeTokenize(p, buffer, 256);
cout << "Hey dummy, here's a field: " << buffer << endl;
}
return 0;
}