Man page - strcat(3)

Packages contains this manual

Available languages:

en fr pl ja ro de

Manual

strcpy

NOM
BIBLIOTHÈQUE
SYNOPSIS
DESCRIPTION
VALEUR RENVOYÉE
ATTRIBUTS
STANDARDS
STANDARDS
AVERTISSEMENTS
EXEMPLES
VOIR AUSSI
TRADUCTION

NOM

stpcpy, strcpy, strcat - Copier ou concaténer une chaßne

BIBLIOTHÈQUE

BibliothĂšque C standard ( libc , -lc )

SYNOPSIS

#include <string.h>

char *stpcpy(char *restrict dst , const char *restrict src );
char *strcpy(char *restrict
dst , const char *restrict src );
char *strcat(char *restrict
dst , const char *restrict src );

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

stpcpy () :
Depuis la glibc 2.10 :
_POSIX_C_SOURCE >= 200809L
Avant la glibc 2.10 :
_GNU_SOURCE

DESCRIPTION

stpcpy ()
strcpy
()

Ces fonctions copient la chaĂźne pointĂ©e par src dans une chaĂźne dans le tampon pointĂ© par dst . Le programmeur est responsable de l’allocation d’un tampon de destination suffisamment grand, c’est-Ă -dire strlen(src) + 1 . Pour la diffĂ©rence entre les deux fonctions voir VALEUR RENVOYÉE.

strcat ()

Cette fonction concatĂšne la chaĂźne pointĂ©e par src aprĂšs la chaĂźne pointĂ©e par dst (Ă©crasant son octet NULL final). Le programmeur est responsable de l’allocation d’un tampon de destination suffisamment grand, c’est-Ă -dire strlen(dst) + strlen(src) + 1 .

Une implĂ©mentation de ces fonctions pourrait ĂȘtre :

char *
stpcpy(char *restrict dst, const char *restrict src)
{
char *p;
p = mempcpy(dst, src, strlen(src));
*p = '\0';
return p;
}
char *
strcpy(char *restrict dst, const char *restrict src)
{
stpcpy(dst, src);
return dst;
}
char *
strcat(char *restrict dst, const char *restrict src)
{
stpcpy(dst + strlen(dst), src);
return dst;
}

VALEUR RENVOYÉE

stpcpy ()

Cette fonction renvoie un pointeur vers l’octet NULL final de la chaĂźne copiĂ©e.

strcpy ()
strcat
()

Ces fonctions renvoient dst .

ATTRIBUTS

Pour une explication des termes utilisés dans cette section, consulter attributes (7).

Image grohtml-3890891-1.png

STANDARDS

stpcpy ()

POSIX.1-2008.

strcpy ()
strcat
()

C11, POSIX.1-2008.

STANDARDS

stpcpy ()

POSIX.1-2008.

strcpy ()
strcat
()

POSIX.1-2001, C89, SVr4, 4.3BSD.

AVERTISSEMENTS

Les chaĂźnes src et dst ne doivent pas se chevaucher.

Si le tampon de destination n’est pas assez grand, le comportement est indĂ©fini. Voir _FORTIFY_SOURCE dans feature_test_macros (7).

strcat () peut ĂȘtre trĂšs inefficace. Lire Ă  ce sujet Shlemiel the painter .

EXEMPLES

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(void)
{
char *p;
char *buf1;
char *buf2;
size_t len, maxsize;
maxsize = strlen("Hello ") + strlen("world") + strlen("!") + 1;
buf1 = malloc(sizeof(*buf1) * maxsize);
if (buf1 == NULL)
err(EXIT_FAILURE, "malloc()");
buf2 = malloc(sizeof(*buf2) * maxsize);
if (buf2 == NULL)
err(EXIT_FAILURE, "malloc()");
p = buf1;
p = stpcpy(p, "Hello ");
p = stpcpy(p, "world");
p = stpcpy(p, "!");
len = p - buf1;
printf("[len = %zu]: ", len);
puts(buf1); // "Hello world!"
free(buf1);
strcpy(buf2, "Hello ");
strcat(buf2, "world");
strcat(buf2, "!");
len = strlen(buf2);
printf("[len = %zu]: ", len);
puts(buf2); // "Hello world!"
free(buf2);
exit(EXIT_SUCCESS);
}

VOIR AUSSI

strdup (3), string (3), wcscpy (3), string_copying (7)

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>, Grégoire Scano <gregoire.scano@malloc.fr> et Jean-Pierre Giraud <jean-pierregiraud@neuf.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 .