1STRTOK(3) Library Functions Manual STRTOK(3)
2
3
4
6 strtok - string tokens
7
9 #include <string.h>
10
11 char *
12 strtok(str, sep)
13 char *str;
14 char *sep;
15
17 This interface is obsoleted by strsep(3).
18
19 The strtok() function is used to isolate sequential tokens in a null-
20 terminated string, str . These tokens are separated in the string by
21 at least one of the characters in sep . The first time that strtok()
22 is called, str should be specified; subsequent calls, wishing to obtain
23 further tokens from the same string, should pass a null pointer
24 instead. The separator string, sep , must be supplied each time, and
25 may change between calls.
26
27 The strtok() function returns a pointer to the beginning of each subse‐
28 quent token in the string, after replacing the token itself with a NUL
29 character. When no more tokens remain, a null pointer is returned.
30
32 index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), str‐
33 rchr(3), strsep(3), strspn(3), strstr(3
34
36 The strtok() function conforms to ANSI C X3.159-1989 (``ANSI C'').
37
39 There is no way to get tokens from multiple strings simultaneously.
40
41 The System V strtok(), if handed a string containing only delimiter
42 characters, will not alter the next starting point, so that a call to
43 strtok() with a different (or empty) delimiter string may return a non-
44 NULL value. Since this implementation always alters the next starting
45 point, such a sequence of calls would always return NULL.
46
47
48
494.4 Berkeley Distribution January 12, 1996 STRTOK(3)