1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)strsep.3 5.3 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt STRSEP 3 12.Os 13.Sh NAME 14.Nm strsep 15.Nd separate strings 16.Sh SYNOPSIS 17.Fd #include <string.h> 18.Ft char * 19.Fn strsep "char **stringp" "char *delim" 20.Sh DESCRIPTION 21The 22.Fn strsep 23locates in the null-terminated string at 24.Fa *stringp 25the first occurence of any character in 26.Fa delim 27and replaces this with a 28.Ql \e0 , 29records the location of the immediate following character in 30.Fa *stringp , 31then returns the original value of 32.Fa *stringp . 33If no delimiter characters are found, 34.Fn strsep 35sets 36.Fa *stringp 37to 38.Dv NULL ; 39if 40.Fa *stringp 41is initially 42.Dv NULL , 43.Fn strsep 44returns 45.Dv NULL . 46.Sh EXAMPLES 47The following uses 48.Fn strsep 49to parse strings containing runs of white space, 50making up an argument vector: 51.Bd -literal -offset indent 52char inputstring[100]; 53char **argv[51], **ap = argv, *p, *val; 54/* set up inputstring */ 55for (p = inputstring; p != NULL; ) { 56 while ((val = strsep(&p, " \et")) != NULL && *val == '\e0'); 57 *ap++ = val; 58} 59*ap = 0; 60.Ed 61.Sh HISTORY 62The 63.Fn strsep 64function is 65.Ud . 66