date and time created 90/06/23 17:20:37 by trent
[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.\"
7b0a190c 16.\" @(#)strtok.3 5.4 (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
3cf67bdd 24.ft B
7b0a190c
KB
25#include <string.h>
26
3cf67bdd
KB
27char *
28strtok(char *str, const char *sep);
29.ft R
cebe22cb 30.fi
3cf67bdd
KB
31.SH DESCRIPTION
32.ft B
33This interface is obsoleted by strsep(3).
34.ft R
cebe22cb
KB
35.PP
36.I Strtok
37is used to isolate sequential tokens in a null-terminated string,
38.IR str .
39These tokens are separated in the string by
40.B "one or more"
41of the characters in
42.IR sep .
43The first time that
44.I strtok
45is called,
46.I str
47should be specified; subsequent calls, wishing to obtain further tokens
3cf67bdd
KB
48from the same string, should pass a null pointer instead.
49The separator string,
cebe22cb
KB
50.IR sep ,
51must be supplied each time, and may change between calls.
3cf67bdd 52.PP
cebe22cb
KB
53.I Strtok
54returns a pointer to the start of each subsequent token in the string,
3cf67bdd
KB
55after replacing the token itself with a NUL character.
56When no more tokens remain, a null pointer is returned.
57.SH SEE ALSO
58index(3), memchr(3), rindex(3), strchr(3), strcspn(3), strpbrk(3), strrchr(3),
59strsep(3), strspn(3), strstr(3)
60.SH STANDARDS
61.B Strtok
62conforms to ANSI X3.159-1989 (``ANSI C'').
cebe22cb
KB
63.SH BUGS
64There is no way to get tokens from multiple strings simultaneously.
80ed8d03 65.PP
3cf67bdd
KB
66The System V
67.B strtok
68will, if handed a string containing only delimiter characters,
69not alter the next starting point, so that a call to
70.B strtok
71with a different (or empty) delimiter string
72may return a non-NULL value.
73Since this implementation always alters the next starting point,
74such a sequence of calls would always return NULL.