Is it possible to use multiple chars as one delimiter?
I would like a string as separator for another string.
char * input = "inputvalue1SEPARATORSTRINGinputvalue2SEPARATORSTRINGinputvalue2";
char * output = malloc(sizeof(char*));
char * delim = "SEPARATORSTRING";
char * example()
{
char * ptr = strtok(input, delim);
while (ptr != NULL)
{
output = strcat(output, ptrvar);
output = strcat(output, "\n");
ptr = strtok(NULL, delim);
}
return output;
}
Return value printed with printf
:
inputvalue1
inputvalue2
inputvalue3