strsep(3) Library Functions Manual strsep(3) NOM strsep - Extraction de sequence d'une chaine BIBLIOTHEQUE Bibliotheque C standard (libc, -lc) SYNOPSIS #include char *strsep(char **restrict stringp, const char *restrict delim); Exigences de macros de test de fonctionnalites pour la glibc (consulter feature_test_macros(7)) : strsep() : Depuis la glibc 2.19 : _DEFAULT_SOURCE glibc 2.19 et anterieures : _BSD_SOURCE DESCRIPTION If *stringp is NULL, the strsep() function returns NULL and does nothing else. Otherwise, this function finds the first token in the string *stringp that is delimited by one of the bytes in the string delim. This token is terminated by overwriting the delimiter with a null byte ('\0'), and *stringp is updated to point past the token. In case no delimiter was found, the token is taken to be the entire string *stringp, and *stringp is made NULL. VALEUR RENVOYEE La fonction strsep() renvoie un pointeur sur la sequence, c'est-a-dire la valeur originelle de *stringp. ATTRIBUTS Pour une explication des termes utilises dans cette section, consulter attributes(7). +---------------------------------+--------------------------+---------+ |Interface | Attribut | Valeur | +---------------------------------+--------------------------+---------+ |strsep() | Securite des threads | MT-Safe | +---------------------------------+--------------------------+---------+ STANDARDS BSD. HISTORIQUE 4.4BSD. The strsep() function was introduced as a replacement for strtok(3), since the latter cannot handle empty fields. CAVEATS Faites attention quand vous utilisez cette fonction. Si vous l'utilisez, prenez note des informations suivantes : - Cette fonction modifie son premier argument. - Cette fonction ne peut pas etre utilisee avec des chaines constantes. - L'identite du caractere delimiteur est perdue. EXEMPLES Le programme ci-dessous est un portage d'un programme trouve dans strtok(3), qui neanmoins n'adandonne pas delimiteurs multiples ou de sequences vides : $ ./a.out 'a/bbb///cc;xxx:yyy:' ':;' '/' 1: a/bbb///cc --> a --> bbb --> --> --> cc 2: xxx --> xxx 3: yyy --> yyy 4: --> Source du programme #include #include #include int main(int argc, char *argv[]) { char *token, *subtoken; if (argc != 4) { fprintf(stderr, "Usage: %s string delim subdelim\n", argv[0]); exit(EXIT_FAILURE); } for (unsigned int j = 1; (token = strsep(&argv[1], argv[2])); j++) { printf("%u: %s\n", j, token); while ((subtoken = strsep(&token, argv[3]))) printf("\t --> %s\n", subtoken); } exit(EXIT_SUCCESS); } VOIR AUSSI memchr(3), strchr(3), string(3), strpbrk(3), strspn(3), strstr(3), strtok(3) TRADUCTION La traduction francaise de cette page de manuel a ete creee par Christophe Blaess , Stephan Rafin , Thierry Vignaud , Francois Micaux, Alain Portal , Jean-Philippe Guerard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas Francois , Florentin Duneau , Simon Paillard , Denis Barbier , David Prevot , Frederic Hantrais et Gregoire Scano Cette traduction est une documentation libre ; veuillez vous reporter a la GNU General Public License version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITE LEGALE. Si vous decouvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message a . Pages du manuel de Linux 6.12 23 juillet 2024 strsep(3)