strsep

Separates strings.

Format

#include  <string.h>

char *strsep  (char **stringp, char *delim);
Function Variants This function also has variants named _strsep32 and _strsep64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Arguments

stringp
A pointer to a pointer to a character string.
delim
A pointer to a string containing characters to be used as delimeters.

Description

This function locates in stringp, the first occurrence of any character in delim (or the terminating '\0' character) and replaces it with a '\0'. The location of the next character after the delimiter character (or NULL, if the end of the string is reached) is stored in the stringp argument. The original value of the stringp argument is returned.

You can detect an "empty" field; one caused by two adjacent delimiter characters, by comparing the location referenced by the pointer returned in the stringp argument to '\0'.

The stringp argument is initially NULL, strsep returns NULL.

Return Values
NULL  Indicates success. 

Example

    The following example uses strsep to parse a string, containing token delimited by white space, into an argument vector:

        char **ap, **argv[10], *inputstring;
    
        for (ap = argv; (*ap = strsep(&inputstring, " \t")) != NULL;)
     if (**ap != '\0')
         ++ap;
    


Previous Page | Next Page | Table of Contents | Index