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