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