Provided by: manpages-fr-dev_4.26.0-1_all bug

NOM

       strsep - Extraction de séquence d'une chaîne

BIBLIOTHÈQUE

       Bibliothèque C standard (libc, -lc)

SYNOPSIS

       #include <string.h>

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

   Exigences de macros de test de fonctionnalités pour la glibc (consulter feature_test_macros(7)) :

       strsep() :
           Depuis la glibc 2.19 :
               _DEFAULT_SOURCE
           glibc 2.19 et antérieures :
               _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 RENVOYÉE

       La fonction strsep() renvoie un pointeur sur la séquence, c'est-à-dire la valeur originelle de *stringp.

ATTRIBUTS

       Pour une explication des termes utilisés dans cette section, consulter attributes(7).
       ┌──────────────────────────────────────────────────────────────────────┬──────────────────────┬─────────┐
       │ InterfaceAttributValeur  │
       ├──────────────────────────────────────────────────────────────────────┼──────────────────────┼─────────┤
       │ strsep()                                                             │ Sécurité des threads │ MT-Safe │
       └──────────────────────────────────────────────────────────────────────┴──────────────────────┴─────────┘

STANDARDS

       Aucun.

HISTORIQUE

       4.4BSD.

       La fonction strsep() a été introduite en remplacement de strtok(3), qui ne peut pas  traiter  les  champs
       vides. Néanmoins, strtok(3) est conforme à C89/C99 et est donc plus portable.

BOGUES

       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 être utilisée avec des chaînes constantes.

       -  L’identité du caractère délimiteur est perdue.

EXEMPLES

       Le programme ci-dessous est un portage d'un programme trouvé dans strtok(3),  qui  néanmoins  n'adandonne
       pas délimiteurs multiples ou de séquences 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 <stdio.h>
       #include <stdlib.h>
       #include <string.h>

       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   française   de   cette   page   de   manuel   a   été   créée   par  Christophe  Blaess
       <https://www.blaess.fr/christophe/>,   Stéphan   Rafin   <stephan.rafin@laposte.net>,   Thierry   Vignaud
       <tvignaud@mandriva.com>,  François  Micaux,  Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard
       <fevrier@tigreraye.org>,   Jean-Luc   Coulon   (f5ibh)   <jean-luc.coulon@wanadoo.fr>,   Julien   Cristau
       <jcristau@debian.org>,      Thomas      Huriaux      <thomas.huriaux@gmail.com>,     Nicolas     François
       <nicolas.francois@centraliens.net>,    Florentin    Duneau    <fduneau@gmail.com>,     Simon     Paillard
       <simon.paillard@resel.enst-bretagne.fr>,     Denis    Barbier    <barbier@debian.org>,    David    Prévot
       <david@tilapin.org>, Frédéric Hantrais <fhantrais@gmail.com> et Grégoire Scano <gregoire.scano@malloc.fr>

       Cette traduction est une documentation libre ; veuillez vous  reporter  à  la  GNU General Public License
       version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

       Si  vous  découvrez  un  bogue  dans la traduction de cette page de manuel, veuillez envoyer un message à
       debian-l10n-french@lists.debian.org.

Pages du manuel de Linux 6.9.1                    15 juin 2024                                         strsep(3)