my previous version was wrong; this one is right
[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.\"
91cff1e1 4.\" %sccs.include.redist.man%
cebe22cb 5.\"
91cff1e1 6.\" @(#)strtok.3 5.5 (Berkeley) %G%
cebe22cb
KB
7.\"
8.TH STRTOK 3 ""
9.UC 3
10.SH NAME
11strtok, strsep \- string token operations
12.SH SYNOPSIS
13.nf
3cf67bdd 14.ft B
7b0a190c
KB
15#include <string.h>
16
3cf67bdd
KB
17char *
18strtok(char *str, const char *sep);
19.ft R
cebe22cb 20.fi
3cf67bdd
KB
21.SH DESCRIPTION
22.ft B
23This interface is obsoleted by strsep(3).
24.ft R
cebe22cb
KB
25.PP
26.I Strtok
27is used to isolate sequential tokens in a null-terminated string,
28.IR str .
29These tokens are separated in the string by
30.B "one or more"
31of the characters in
32.IR sep .
33The first time that
34.I strtok
35is called,
36.I str
37should be specified; subsequent calls, wishing to obtain further tokens
3cf67bdd
KB
38from the same string, should pass a null pointer instead.
39The separator string,
cebe22cb
KB
40.IR sep ,
41must be supplied each time, and may change between calls.
3cf67bdd 42.PP
cebe22cb
KB
43.I Strtok
44returns a pointer to the start of each subsequent token in the string,
3cf67bdd
KB
45after replacing the token itself with a NUL character.
46When no more tokens remain, a null pointer is returned.
47.SH SEE ALSO
48index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), strrchr(3),
49strsep(3), strspn(3), strstr(3)
50.SH STANDARDS
51.B Strtok
52conforms to ANSI X3.159-1989 (``ANSI C'').
cebe22cb
KB
53.SH BUGS
54There is no way to get tokens from multiple strings simultaneously.
80ed8d03 55.PP
3cf67bdd
KB
56The System V
57.B strtok
58will, if handed a string containing only delimiter characters,
59not alter the next starting point, so that a call to
60.B strtok
61with a different (or empty) delimiter string
62may return a non-NULL value.
63Since this implementation always alters the next starting point,
64such a sequence of calls would always return NULL.