xref: /csrg-svn/lib/libc/string/strtok.3 (revision 50328)
148351Scael.\" Copyright (c) 1988, 1991 The Regents of the University of California.
236216Sbostic.\" All rights reserved.
336216Sbostic.\"
4*50328Sbostic.\" This code is derived from software contributed to Berkeley by
5*50328Sbostic.\" the American National Standards Committee X3, on Information
6*50328Sbostic.\" Processing Systems.
7*50328Sbostic.\"
843567Strent.\" %sccs.include.redist.man%
936216Sbostic.\"
10*50328Sbostic.\"     @(#)strtok.3	5.8 (Berkeley) 06/29/91
1136216Sbostic.\"
1248351Scael.Dd
1348351Scael.Dt STRTOK 3
1448351Scael.Os BSD 3
1548351Scael.Sh NAME
1648351Scael.Nm strtok ,
1748351Scael.Nm strsep
1848351Scael.Nd string token operations
1948351Scael.Sh SYNOPSIS
2048351Scael.Fd #include <string.h>
2148351Scael.Ft char *
2248351Scael.Fn strtok "char *str" "const char *sep"
2348351Scael.Sh DESCRIPTION
2448351Scael.Bf -symbolic
2542171SbosticThis interface is obsoleted by strsep(3).
2648351Scael.Ef
2748351Scael.Pp
2848351ScaelThe
2948351Scael.Fn strtok
3048351Scaelfunction
3136216Sbosticis used to isolate sequential tokens in a null-terminated string,
3248351Scael.Fa str .
3348351ScaelThese tokens are separated in the string by at least one of the
3448351Scaelcharacters in
3548351Scael.Fa sep .
3636216SbosticThe first time that
3748351Scael.Fn strtok
3836216Sbosticis called,
3948351Scael.Fa str
4036216Sbosticshould be specified; subsequent calls, wishing to obtain further tokens
4142171Sbosticfrom the same string, should pass a null pointer instead.
4242171SbosticThe separator string,
4348351Scael.Fa sep ,
4436216Sbosticmust be supplied each time, and may change between calls.
4548351Scael.Pp
4648351ScaelThe
4748351Scael.Fn strtok
4848351Scaelfunction
4948351Scaelreturns a pointer to the beginning of each subsequent token in the string,
5048351Scaelafter replacing the token itself with a
5148351Scael.Dv NUL
5248351Scaelcharacter.
5342171SbosticWhen no more tokens remain, a null pointer is returned.
5448351Scael.Sh SEE ALSO
5548351Scael.Xr index 3 ,
5648351Scael.Xr memchr 3 ,
5748351Scael.Xr rindex 3 ,
5848351Scael.Xr strchr 3 ,
5948351Scael.Xr strcspn 3 ,
6048351Scael.Xr strpbrk 3 ,
6148351Scael.Xr strrchr 3 ,
6248351Scael.Xr strsep 3 ,
6348351Scael.Xr strspn 3 ,
6448351Scael.Xr strstr 3
6548351Scael.Sh STANDARDS
6648351ScaelThe
6748351Scael.Fn strtok
6848351Scaelfunction
6948351Scaelconforms to
7048351Scael.St -ansiC .
7148351Scael.Sh BUGS
7236216SbosticThere is no way to get tokens from multiple strings simultaneously.
7348351Scael.Pp
7442171SbosticThe System V
7548351Scael.Fn strtok ,
7648351Scaelif handed a string containing only delimiter characters,
7748351Scaelwill not alter the next starting point, so that a call to
7848351Scael.Fn strtok
7942171Sbosticwith a different (or empty) delimiter string
8048351Scaelmay return a
8148351Scael.Pf non- Dv NULL
8248351Scaelvalue.
8342171SbosticSince this implementation always alters the next starting point,
8448351Scaelsuch a sequence of calls would always return
8548351Scael.Dv NULL .
86