VMS Help  —  CRTL  strsep
    Separates strings.

    Format

      #include  <string.h>

      char *strsep  (char **stringp, char *delim);

1  –  Function Variants

    The strsep function has variants named _strsep32 and _strsep64
    for use with 32-bit and 64-bit pointer sizes, respectively.

2  –  Arguments

 stringp

    A pointer to a pointer to a character string.

 delim

    A pointer to a string containing characters to be used as
    delimiters.

3  –  Description

    The strsep 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.

4  –  Return Values

    x                  The address of the string pointed to by
                       stringp.
    NULL               Indicates that stringp is NULL.

5  –  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;
Close Help