I need in my program to call strtok twice, one inside the other. The problem I’ve got is that the first strtok cannot resume the loop after executing the inside strtok and it loses the pointer of the first char.
To explain more here is an example:
main :
tokens = strtok (stmt, ":");
while (tokens != NULL) {
convert_field(tokens);
tokens = strtok (NULL, ":");
}
in the convert_field function I do
tokens = strtok (sub_stmt, ".->//");
while (tokens != NULL) {
convert_field(tokens);
tokens = strtok (NULL, ".->//");
}
strtokis not reentrant (which means you cannot call the function again before it finishes its previous execution), you have to usestrtok_r(which is reentrant) instead.