I am back with C++ after 15 years...I just can't remember why we need the address of a pointer. Like in this statement:
char *next_token = NULL;
char *pszMozilla = strtok_s(szCopyVariable, "/", &next_token);
Is there an assumption that the address of the pointer will represent eventually the start of a list of pointers ?
strtok_s
is a reentrant function, and it needs to store some state somewhere. That state is a pointer to the character one after the last one it processed. (Think about it, that's really all you need to resume tokenizing.)
If a function wants to store an X in a user-provided space, the user needs to provide a pointer to an X, pointing to where the X will go. In our case, X is a "pointer to char".
那是因为strtok_s()
通过在每次调用时移动next_token
维护状态。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.