Is there a way in C to split a string (using strtok or any other way) where the delimiter is more than one character in length? I\'m looking for something like
Something like this maybe? No guarantees that this compiles. ;)
char* strstrtok(char *haystack, char *needle) {
static char *remaining = null;
char *working;
if(haystack)
working = haystack;
else if(remaining)
working = remaining;
else
return NULL;
char *result = working;
if(result = strstr(working, needle))
remaining = working + strlen(needle) + 1;
return result;
}