Commit | Line | Data |
---|---|---|
ae59e04c | 1 | .\" Copyright (c) 1988, 1991 The Regents of the University of California. |
cebe22cb KB |
2 | .\" All rights reserved. |
3 | .\" | |
043368e6 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the American National Standards Committee X3, on Information | |
6 | .\" Processing Systems. | |
7 | .\" | |
91cff1e1 | 8 | .\" %sccs.include.redist.man% |
cebe22cb | 9 | .\" |
043368e6 | 10 | .\" @(#)strtok.3 5.8 (Berkeley) %G% |
cebe22cb | 11 | .\" |
ae59e04c CL |
12 | .Dd |
13 | .Dt STRTOK 3 | |
14 | .Os BSD 3 | |
15 | .Sh NAME | |
16 | .Nm strtok , | |
17 | .Nm strsep | |
18 | .Nd string token operations | |
19 | .Sh SYNOPSIS | |
20 | .Fd #include <string.h> | |
21 | .Ft char * | |
22 | .Fn strtok "char *str" "const char *sep" | |
23 | .Sh DESCRIPTION | |
24 | .Bf -symbolic | |
3cf67bdd | 25 | This interface is obsoleted by strsep(3). |
ae59e04c CL |
26 | .Ef |
27 | .Pp | |
28 | The | |
29 | .Fn strtok | |
30 | function | |
cebe22cb | 31 | is used to isolate sequential tokens in a null-terminated string, |
ae59e04c CL |
32 | .Fa str . |
33 | These tokens are separated in the string by at least one of the | |
34 | characters in | |
35 | .Fa sep . | |
cebe22cb | 36 | The first time that |
ae59e04c | 37 | .Fn strtok |
cebe22cb | 38 | is called, |
ae59e04c | 39 | .Fa str |
cebe22cb | 40 | should be specified; subsequent calls, wishing to obtain further tokens |
3cf67bdd KB |
41 | from the same string, should pass a null pointer instead. |
42 | The separator string, | |
ae59e04c | 43 | .Fa sep , |
cebe22cb | 44 | must be supplied each time, and may change between calls. |
ae59e04c CL |
45 | .Pp |
46 | The | |
47 | .Fn strtok | |
48 | function | |
49 | returns a pointer to the beginning of each subsequent token in the string, | |
50 | after replacing the token itself with a | |
51 | .Dv NUL | |
52 | character. | |
3cf67bdd | 53 | When no more tokens remain, a null pointer is returned. |
ae59e04c CL |
54 | .Sh SEE ALSO |
55 | .Xr index 3 , | |
56 | .Xr memchr 3 , | |
57 | .Xr rindex 3 , | |
58 | .Xr strchr 3 , | |
59 | .Xr strcspn 3 , | |
60 | .Xr strpbrk 3 , | |
61 | .Xr strrchr 3 , | |
62 | .Xr strsep 3 , | |
63 | .Xr strspn 3 , | |
64 | .Xr strstr 3 | |
65 | .Sh STANDARDS | |
66 | The | |
67 | .Fn strtok | |
68 | function | |
69 | conforms to | |
70 | .St -ansiC . | |
71 | .Sh BUGS | |
cebe22cb | 72 | There is no way to get tokens from multiple strings simultaneously. |
ae59e04c | 73 | .Pp |
3cf67bdd | 74 | The System V |
ae59e04c CL |
75 | .Fn strtok , |
76 | if handed a string containing only delimiter characters, | |
77 | will not alter the next starting point, so that a call to | |
78 | .Fn strtok | |
3cf67bdd | 79 | with a different (or empty) delimiter string |
ae59e04c CL |
80 | may return a |
81 | .Pf non- Dv NULL | |
82 | value. | |
3cf67bdd | 83 | Since this implementation always alters the next starting point, |
ae59e04c CL |
84 | such a sequence of calls would always return |
85 | .Dv NULL . |