Index of Section 3 Manual Pages
| Interix / SUA | strtok.3 | Interix / SUA |
strtok(3) strtok(3)
strtok()
NAME
strtok(), strtok_r() - string tokens
SYNOPSIS
#include
char * strtok (char *str, const char *sep)
char * strtok_r (char *str, const char *sep,
char **lasts)
DESCRIPTION
The strtok(3) function is used to isolate sequential tokens in a null-
terminated string, str. These tokens are separated in the string by at
least one of the characters in sep. The first time that strtok(3) is
called, str should be specified; subsequent calls, wishing to obtain
further tokens from the same string, should pass a null pointer instead.
The separator string, sep, must be supplied each time, and may change
between calls.
The strtok(3) function returns a pointer to the beginning of each
subsequent token in the string, after replacing the token itself with a
NUL character. When no more tokens remain, a null pointer is returned.
The reentrant strtok_r(3) function assumes that the null-terminated string
identified by the str argument is a sequence of zero or more text tokens
separated by spans of one or more characters from the separator string
identified by the sep argument. The argument lasts points to a user-
provided pointer that points to stored information necessary for
strtok_r(3) to continue scanning the same string.
In the first call to strtok_r(3), str points to a null-terminated string,
sep points to a null-terminated string of separator characters, and lasts
is ignored. The strtok_r(3) function returns a pointer to the first
character of the first token, writes a null character into str immediately
following the returned token, and updates the pointer to which lasts
points.
In subsequent calls, str is a NULL pointer and lasts is unchanged from the
previous call so that subsequent calls move through the string str,
returning successive tokens until no tokens remain. The separator string
sep can be different from call to call. When no token remains in str, a
NULL pointer is returned.
SEE ALSO
memchr(3)
strchr(3)
strcspn(3)
strpbrk(3)
strrchr(3)
strsep(3)
strspn(3)
strstr(3)
USAGE NOTES
The strtok_r function is thread safe. The strtok function is not thread
safe.
None of these functions are async-signal safe.