STRSEP(3) BSD Programmer's Manual STRSEP(3) NNAAMMEE ssttrrsseepp - separate strings SSYYNNOOPPSSIISS ##iinncclluuddee <<ssttrriinngg..hh>> _c_h_a_r _* ssttrrsseepp(_c_h_a_r _*_*_s_t_r_i_n_g_p, _c_h_a_r _*_d_e_l_i_m); DDEESSCCRRIIPPTTIIOONN The ssttrrsseepp() function locates, in the string referenced by _*_s_t_r_i_n_g_p, the first occurrence of any character in the string _d_e_l_i_m (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 was reached) is stored in _*_s_t_r_i_n_g_p. The original value of _*_s_t_r_i_n_g_p is returned. An ``empty'' field, i.e. one caused by two adjacent delimiter characters, can be detected by comparing the location referenced by the pointer re- turned in _*_s_t_r_i_n_g_p to `\0'. If _*_s_t_r_i_n_g_p is initially NULL, ssttrrsseepp() returns NULL. EEXXAAMMPPLLEESS The following uses ssttrrsseepp() to parse a string, containing tokens delimit- ed by white space, into an argument vector: char **ap, *argv[10], *inputstring; for (ap = argv; (*ap = strsep(&inputstring, " \t")) != NULL;) if (**ap != '\0') ++ap; HHIISSTTOORRYY The ssttrrsseepp() function is intended as a replacement for the ssttrrttookk() func- tion. While the ssttrrttookk() function should be preferred for portability reasons (it conforms to ANSI C X3.159-1989 (``ANSI C '')) it is unable to handle empty fields, i.e. detect fields delimited by two adjacent delim- iter characters, or to be used for more than a single string at a time. The ssttrrsseepp() function first appeared in 4.4BSD. 4.4BSD June 9, 1993 1