Implementation of strtok
Florian Weimer
fweimer@redhat.com
Fri Jun 2 06:05:13 GMT 2023
* Jayakrishna Vadayath:
> The man page of strtok mention that strtok returns a pointer to the
> next token or NULL if there are no more tokens :
> https://man7.org/linux/man-pages/man3/strtok.3.html I can see how the
> "no more tokens" would apply in this case, but it seems like not many
> people are aware of this case.
>
> Can you list the descriptions of strtok that explain this behavior ?
This part is quite clear to me:
| The first call to strtok() sets this pointer to point to the first
| byte of the string. The start of the next token is determined by
| scanning forward for the next nondelimiter byte in str. If such a
| byte is found, it is taken as the start of the next token. If no such
| byte is found, then there are no more tokens, and strtok() returns
| NULL.
The last sentence is really unambiguous. Maybe it's the double
negation?
Thanks,
Florian
More information about the Libc-alpha
mailing list