STRSEP

Section: C Library Functions (3)
Index Return to Main Contents

BSD mandoc
 

NAME

strsep - separate strings  

SYNOPSIS

Fd #include <string.h> Ft char * Fn strsep char **stringp char *delim  

DESCRIPTION

The Fn strsep locates in the null-terminated string at Fa *stringp the first occurrence of any character in Fa delim and replaces this with a `\0' , 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 NULL if Fa *stringp is initially NULL Fn strsep returns NULL  

EXAMPLES

The following uses Fn strsep to parse strings containing runs of white space, making up an argument vector:
char inputstring[100];
char **argv[51], **ap = argv, *p, *val;
/* set up inputstring */
for (p = inputstring; p != NULL; ) {
        while ((val = strsep(&p, " \t")) != NULL && *val == '\0');
        *ap++ = val;
}
*ap = 0;
 

HISTORY

The Fn strsep function is Ud .


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
HISTORY

This document was created by man2html, using the manual pages.
Time: 15:52:50 GMT, January 15, 2023