xref: /csrg-svn/lib/libc/string/strtok.3 (revision 65981)
161193Sbostic.\" Copyright (c) 1988, 1991, 1993
261193Sbostic.\"	The Regents of the University of California.  All rights reserved.
336216Sbostic.\"
450328Sbostic.\" This code is derived from software contributed to Berkeley by
550328Sbostic.\" the American National Standards Committee X3, on Information
650328Sbostic.\" Processing Systems.
750328Sbostic.\"
843567Strent.\" %sccs.include.redist.man%
936216Sbostic.\"
10*65981Sbostic.\"     @(#)strtok.3	8.2 (Berkeley) 02/03/94
1136216Sbostic.\"
1248351Scael.Dd
1348351Scael.Dt STRTOK 3
1448351Scael.Os BSD 3
1548351Scael.Sh NAME
16*65981Sbostic.Nm strtok
17*65981Sbostic.Nd string tokens
1848351Scael.Sh SYNOPSIS
1948351Scael.Fd #include <string.h>
2048351Scael.Ft char *
2148351Scael.Fn strtok "char *str" "const char *sep"
2248351Scael.Sh DESCRIPTION
2348351Scael.Bf -symbolic
2442171SbosticThis interface is obsoleted by strsep(3).
2548351Scael.Ef
2648351Scael.Pp
2748351ScaelThe
2848351Scael.Fn strtok
2948351Scaelfunction
3036216Sbosticis used to isolate sequential tokens in a null-terminated string,
3148351Scael.Fa str .
3248351ScaelThese tokens are separated in the string by at least one of the
3348351Scaelcharacters in
3448351Scael.Fa sep .
3536216SbosticThe first time that
3648351Scael.Fn strtok
3736216Sbosticis called,
3848351Scael.Fa str
3936216Sbosticshould be specified; subsequent calls, wishing to obtain further tokens
4042171Sbosticfrom the same string, should pass a null pointer instead.
4142171SbosticThe separator string,
4248351Scael.Fa sep ,
4336216Sbosticmust be supplied each time, and may change between calls.
4448351Scael.Pp
4548351ScaelThe
4648351Scael.Fn strtok
4748351Scaelfunction
4848351Scaelreturns a pointer to the beginning of each subsequent token in the string,
4948351Scaelafter replacing the token itself with a
5048351Scael.Dv NUL
5148351Scaelcharacter.
5242171SbosticWhen no more tokens remain, a null pointer is returned.
5348351Scael.Sh SEE ALSO
5448351Scael.Xr index 3 ,
5548351Scael.Xr memchr 3 ,
5648351Scael.Xr rindex 3 ,
5748351Scael.Xr strchr 3 ,
5848351Scael.Xr strcspn 3 ,
5948351Scael.Xr strpbrk 3 ,
6048351Scael.Xr strrchr 3 ,
6148351Scael.Xr strsep 3 ,
6248351Scael.Xr strspn 3 ,
6348351Scael.Xr strstr 3
6448351Scael.Sh STANDARDS
6548351ScaelThe
6648351Scael.Fn strtok
6748351Scaelfunction
6848351Scaelconforms to
6948351Scael.St -ansiC .
7048351Scael.Sh BUGS
7136216SbosticThere is no way to get tokens from multiple strings simultaneously.
7248351Scael.Pp
7342171SbosticThe System V
7448351Scael.Fn strtok ,
7548351Scaelif handed a string containing only delimiter characters,
7648351Scaelwill not alter the next starting point, so that a call to
7748351Scael.Fn strtok
7842171Sbosticwith a different (or empty) delimiter string
7948351Scaelmay return a
8048351Scael.Pf non- Dv NULL
8148351Scaelvalue.
8242171SbosticSince this implementation always alters the next starting point,
8348351Scaelsuch a sequence of calls would always return
8448351Scael.Dv NULL .
85