macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / string / strtok.3
CommitLineData
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 21This interface is obsoleted by strsep(3).
ae59e04c
CL
22.Ef
23.Pp
24The
25.Fn strtok
26function
cebe22cb 27is used to isolate sequential tokens in a null-terminated string,
ae59e04c
CL
28.Fa str .
29These tokens are separated in the string by at least one of the
30characters in
31.Fa sep .
cebe22cb 32The first time that
ae59e04c 33.Fn strtok
cebe22cb 34is called,
ae59e04c 35.Fa str
cebe22cb 36should be specified; subsequent calls, wishing to obtain further tokens
3cf67bdd
KB
37from the same string, should pass a null pointer instead.
38The separator string,
ae59e04c 39.Fa sep ,
cebe22cb 40must be supplied each time, and may change between calls.
ae59e04c
CL
41.Pp
42The
43.Fn strtok
44function
45returns a pointer to the beginning of each subsequent token in the string,
46after replacing the token itself with a
47.Dv NUL
48character.
3cf67bdd 49When 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
62The
63.Fn strtok
64function
65conforms to
66.St -ansiC .
67.Sh BUGS
cebe22cb 68There is no way to get tokens from multiple strings simultaneously.
ae59e04c 69.Pp
3cf67bdd 70The System V
ae59e04c
CL
71.Fn strtok ,
72if handed a string containing only delimiter characters,
73will not alter the next starting point, so that a call to
74.Fn strtok
3cf67bdd 75with a different (or empty) delimiter string
ae59e04c
CL
76may return a
77.Pf non- Dv NULL
78value.
3cf67bdd 79Since this implementation always alters the next starting point,
ae59e04c
CL
80such a sequence of calls would always return
81.Dv NULL .