(ANSI Standard)
#include <string.h> ptr = strtok( s1, s2 );
"strtok" obtains one token at a time from a string. The first call to "strtok" should pass a pointer to the string in the "s1" argument. Subsequent calls to obtain more tokens from the string should pass the NULL pointer as "s1". Between calls, "strtok" keeps a pointer in local static storage to remember where the last token was. The string of separators "s2" may be changed between calls.
When "strtok" finds a token in the string, it replaces the separator character at the end of the token with a "\0". In this way, the token looks just like a normal null-terminated string.
Because this function uses a static storage area, it should not be called by code that needs to be re-entrant (e.g. exception handlers).
Copyright © 1996, Thinkage Ltd.