The (BSD) man pages for strtok
state in the first line under description
This interface is obsoleted by
strsep(3)
.
Does that mean that strtok
should on the whole not be used? It does not provide any usage guidelines about strtok
's being obsolete beyond that. On strsep
's man page, it states under history
The
strsep()
function is intended as a replacement for thestrtok()
function. While thestrtok()
function should be preferred for portability reasons (it conforms to ISO/IEC 9899:1990 (``ISO C90'')) it is unable to handle empty fields, i.e., detect fields delimited by two adjacent delimiter characters, or to be used for more than a single string at a time.
So, my questions are this
- Should
strsep
on the whole be used overstrtok
? - How much of a portability issue is there with
strsep
as it appeared in BSD4.4 which was in June of 1994? - Do all POSIX compliant machines have
strsep
?