Code:
char *strtok(char *s1, const char *s2);
If
s1 is not a null pointer, the function begins a search of the string
s1. Otherwise, it begins a search of the string whose address was last stored in an internal static-duration object on an earlier call to the function, as described below. The search proceeds as follows:
The function searches the string for
begin, the address of the first element that equals
none of the elements of the string
s2 (a set of token separators). It considers the terminating null character as part of the search string only.
If the search does not find an element, the function stores the address of the terminating null character in the internal static-duration object (so that a subsequent search beginning with that address will fail) and returns a null pointer. Otherwise, the function searches from
begin for
end, the address of the first element that equals
any one of the elements of the string
s2. It again considers the terminating null character as part of the search string only.
If the search does not find an element, the function stores the address of the terminating null character in the internal static-duration object. Otherwise, it stores a null character in the element whose address is
end. Then it stores the address of the next element after end in the internal static-duration object (so that a subsequent search beginning with that address will continue with the remaining elements of the string) and returns
begin.