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