don't need rindex reference
[unix-history] / usr / src / lib / libc / string / strtok.3
CommitLineData
cebe22cb
KB
1.\" Copyright (c) 1988 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
80ed8d03 16.\" @(#)strtok.3 5.2 (Berkeley) %G%
cebe22cb
KB
17.\"
18.TH STRTOK 3 ""
19.UC 3
20.SH NAME
21strtok, strsep \- string token operations
22.SH SYNOPSIS
23.nf
24.B char *strtok(str, sep)
25.B char *str, *sep;
26.PP
27.B char *strsep(str, sep)
28.B char *str, *sep;
29.fi
30.PP
31.I Strtok
32is used to isolate sequential tokens in a null-terminated string,
33.IR str .
34These tokens are separated in the string by
35.B "one or more"
36of the characters in
37.IR sep .
38The first time that
39.I strtok
40is called,
41.I str
42should be specified; subsequent calls, wishing to obtain further tokens
43from the same string, should pass a null pointer instead. The separator
44string,
45.IR sep ,
46must be supplied each time, and may change between calls.
47.I Strtok
48returns a pointer to the start of each subsequent token in the string,
49after replacing the token itself with a NUL character. When no more
50tokens remain, a null pointer is returned.
51.PP
52.I Strsep
53behaves similarly to
54.I strtok
55with the exception that the tokens in the string are separated by single
56occurrences of separator characters. This routine was added to allow
57handling blank fields.
58.SH BUGS
59There is no way to get tokens from multiple strings simultaneously.
80ed8d03
KB
60.PP
61.I Strsep
62is used heavily in the C library; calls to it and calls to the C library
63should not be intermixed.