.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 2022 Alejandro Colomar .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH strcpy 3 "20 juillet 2023" "Pages du manuel de Linux 6.05.01" .SH NOM stpcpy, strcpy, strcat \- Copier ou concaténer une chaîne .SH BIBLIOTHÈQUE Bibliothèque C standard (\fIlibc\fP, \fI\-lc\fP) .SH SYNOPSIS .nf \fB#include \fP .PP \fBchar *stpcpy(char *restrict \fP\fIdst\fP\fB, const char *restrict \fP\fIsrc\fP\fB);\fP \fBchar *strcpy(char *restrict \fP\fIdst\fP\fB, const char *restrict \fP\fIsrc\fP\fB);\fP \fBchar *strcat(char *restrict \fP\fIdst\fP\fB, const char *restrict \fP\fIsrc\fP\fB);\fP .fi .PP .RS -4 Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .RE .PP \fBstpcpy\fP()\ : .nf Depuis la glibc 2.10 : _POSIX_C_SOURCE >= 200809L Avant la glibc 2.10 : _GNU_SOURCE .fi .SH DESCRIPTION .TP \fBstpcpy\fP() .TQ \fBstrcpy\fP() Ces fonctions copient la chaîne pointée par \fIsrc\fP dans une chaîne dans le tampon pointé par \fIdst\fP. Le programmeur est responsable de l'allocation d'un tampon de destination suffisamment grand, c'est\-à\-dire \fIstrlen(src)\ +\ 1\fP. Pour la différence entre les deux fonctions voir VALEUR RENVOYÉE. .TP \fBstrcat\fP() Cette fonction concatène la chaîne pointée par \fIsrc\fP après la chaîne pointée par \fIdst\fP (écrasant son octet NULL final). Le programmeur est responsable de l'allocation d'un tampon de destination suffisamment grand, c'est\-à\-dire \fIstrlen(dst)\ + strlen(src) +\ 1\fP. .PP Une implémentation de ces fonctions pourrait être\ : .PP .in +4n .EX char * stpcpy(char *restrict dst, const char *restrict src) { char *p; \& p = mempcpy(dst, src, strlen(src)); *p = \[aq]\e0\[aq]; \& 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; } .EE .in .SH "VALEUR RENVOYÉE" .TP \fBstpcpy\fP() Cette fonction renvoie un pointeur vers l'octet NULL final de la chaîne copiée. .TP \fBstrcpy\fP() .TQ \fBstrcat\fP() Ces fonctions renvoient \fIdst\fP. .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. Interface Attribut Valeur T{ .na .nh \fBstpcpy\fP(), \fBstrcpy\fP(), \fBstrcat\fP() T} Sécurité des threads MT\-Safe .TE .sp 1 .SH STANDARDS .TP \fBstpcpy\fP() POSIX.1\-2008. .TP \fBstrcpy\fP() .TQ \fBstrcat\fP() C11, POSIX.1\-2008. .SH STANDARDS .TP \fBstpcpy\fP() POSIX.1\-2008. .TP \fBstrcpy\fP() .TQ \fBstrcat\fP() POSIX.1\-2001, C89, SVr4, 4.3BSD. .SH AVERTISSEMENTS Les chaînes \fIsrc\fP et \fIdst\fP ne doivent pas se chevaucher. .PP Si le tampon de destination n'est pas assez grand, le comportement est indéfini. Voir \fB_FORTIFY_SOURCE\fP dans \fBfeature_test_macros\fP(7). .PP \fBstrcat\fP() peut être très inefficace. Lire à ce sujet .UR https://www.joelonsoftware.com/\:2001/12/11/\:back\-to\-basics/ Shlemiel the\ painter .UE . .SH EXEMPLES .\" SRC BEGIN (strcpy.c) .EX #include #include #include #include \& 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); } .EE .\" SRC END .SH "VOIR AUSSI" \fBstrdup\fP(3), \fBstring\fP(3), \fBwcscpy\fP(3), \fBstring_copying\fP(7) .PP .SH TRADUCTION La traduction française de cette page de manuel a été créée par Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier , David Prévot , Frédéric Hantrais , Grégoire Scano et Jean-Pierre Giraud . .PP Cette traduction est une documentation libre ; veuillez vous reporter à la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License version 3 .UE concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE. .PP Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à .MT debian-l10n-french@lists.debian.org .ME .