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 this:
char a[14] = "Hello,World!";
char *b[2];
b[0] = strtok(a, ", ");
b[1] = strtok(NULL, ", ");
I want this to not split the string because there is no space between the comma and the W. Is there a way to do that?
You could just repeatedly call
substrto find occurrences of your boundary string and split along the results. After you found a result, advance the pointer by the length of the substring and search again.