4.3BSD-Reno/src/lib/libc/string/strsep.3

Compare this file to the similar file:
Show the results in this format:

.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Chris Torek.
.\"
.\" Redistribution and use in source and binary forms are permitted
.\" provided that: (1) source distributions retain this entire copyright
.\" notice and comment, and (2) distributions including binaries display
.\" the following acknowledgement:  ``This product includes software
.\" developed by the University of California, Berkeley and its contributors''
.\" in the documentation or other materials provided with the distribution
.\" and in all advertising materials mentioning features or use of this
.\" software. Neither the name of the University nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.\"	@(#)strsep.3	5.1 (Berkeley) 5/15/90
.\"
.TH STRSEP 3 "May 15, 1990"
.UC 7
.SH NAME
strsep \- separate strings
.SH SYNOPSIS
.nf
.ft B
#include <string.h>

char *
strsep(char **stringp, char *delim);
.ft R
.fi
.SH DESCRIPTION
.B Strsep
locates in the null-terminated string at
.I *stringp
the first occurence of any character in
.I delim
and replaces this with a '\e0',
records the location of the immediate following character in
.IR *stringp ,
then returns the original value of
.IR *stringp .
If no delimiter characters are found,
.B strsep
sets
.I *stringp
to NULL;
if
.I *stringp
is initially NULL,
.B strsep
returns NULL.
.SH EXAMPLES
The following uses
.I strsep
to parse strings containing runs of white space,
making up an argument vector:
.sp
.nf
.RS
char inputstring[100];
char **argv[51], **ap = argv, *p, *val;
.I "/* set up inputstring */"
for (p = inputstring; p != NULL; ) {
    while ((val = strsep(&p, " \et")) != NULL && *val == '\e0');
    *ap++ = val;
}
*ap = 0;
.RE