Separates strings.
#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.
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.
NULL | Indicates success. |
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;