.\" Copyright (c) 1990, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek. .\" %sccs.include.redist.man% .\" .\" @(#)strsep.3 5.3 (Berkeley) 04/19/91 .\" .Dd .Dt STRSEP 3 .Os .Sh NAME .Nm strsep .Nd separate strings .Sh SYNOPSIS .Fd #include .Ft char * .Fn strsep "char **stringp" "char *delim" .Sh DESCRIPTION The .Fn strsep locates in the null-terminated string at .Fa *stringp the first occurence of any character in .Fa delim and replaces this with a .Ql \e0 , records the location of the immediate following character in .Fa *stringp , then returns the original value of .Fa *stringp . If no delimiter characters are found, .Fn strsep sets .Fa *stringp to .Dv NULL ; if .Fa *stringp is initially .Dv NULL , .Fn strsep returns .Dv NULL . .Sh EXAMPLES The following uses .Fn strsep to parse strings containing runs of white space, making up an argument vector: .Bd -literal -offset indent char inputstring[100]; char **argv[51], **ap = argv, *p, *val; /* set up inputstring */ for (p = inputstring; p != NULL; ) { while ((val = strsep(&p, " \et")) != NULL && *val == '\e0'); *ap++ = val; } *ap = 0; .Ed .Sh HISTORY The .Fn strsep function is .Ud .