I come across the functions like strtok_s where you will need to pass a pointer to pointer argument.
strtok_r(char *restrict str, const char *restrict sep, char **restrict lasts);
The way to use it is:
char *foo;
char *str = ...;
char *delimiter = ...;
strtok_r(str, delimiter, &foo);
Wondering why pass the address of pointer foo into the function?
It’s so that
strtokcan resume where it left off. This version ofstrtokis thread safe (since it uses a pointer you supply and not the internal pointer of the other version).It saves the address of the last token read in a
char *so you need to pass a pointer to that pointer so it can change the value and return it to you.