Implementation of strtok
Jayakrishna Vadayath
jvadayat@asu.edu
Fri Jun 2 06:17:05 GMT 2023
Hi,
Thank you for your reply.
I was only looking at the return value section of the documentation.
However, it makes sense to me now.
Thank you.
On Thu, Jun 1, 2023 at 11:05 PM Florian Weimer <fweimer@redhat.com> wrote:
> * 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://urldefense.com/v3/__https://man7.org/linux/man-pages/man3/strtok.3.html__;!!IKRxdwAv5BmarQ!bQa53ZIha6p2oe0o-luVxpSJFX4pb7VPYYq36zBLfwHYp6-jrFmUvqu99oGfoqfG3qYlrRhyElmpVpse$
> 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
>
>
--
Regards
Jayakrishna Menon
More information about the Libc-alpha
mailing list