[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/string/byte/strcpy [Back]  [Original]

std::strcpy cppreference.com
cppreference.com
Espaces de noms
Variantes

std::strcpy

De cppreference.com
 
 
Bibliothque de chanes de caractres
Chanes zro terminal
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Les chanes d'octets
Chaines multi-octets
Les chanes tendues
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
Chanes d'octets zro terminal
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulation caractre
Original:
Character manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion aux formats numriques
Original:
Conversions to numeric formats
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La manipulation de chanes
Original:
String manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strcpy
strncpy
strcat
strncat
strxfrm
Examen chane
Original:
String examination
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulation de la mmoire
Original:
Memory manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
memchr
memcmp
memset
memcpy
memmove
Divers
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strerror
 
<tbody> </tbody>
Dclar dans l'en-tte <cstring>
char *strcpy( char *dest, const char *src );

Copie (avec le caractre NULL de fin) la chane d'octets pointe par src vers la chane d'octets pointe par dest.

Le comportement est indfini si les chanes se chevauchent, ou si dest n'est pas assez grand.

Paramtres

dest - pointeur sur la chane d'octets vers laquelle copier
src - pointeur sur la chane d'octets termine par NULL copier

Retourne la valeur

dest

Exemple

#include <iostream>
#include <cstring>
#include <memory>

int main()
{
    const char* src = "Casser un test.";
//  src[0] = 'P'; // Impossible de modifier une chane const
    auto dst = std::make_unique<char[]>(std::strlen(src)+1); // +1 pour le null de fin
    std::strcpy(dst.get(), src);
    dst[0] = 'P';
    std::cout << src << '\n' << dst.get() << '\n';
}

Rsultat :

Casser un test.
Passer un test.


Voir aussi

copie d'un certain nombre de caractres d'une chane l'autre
Original:
copies a certain amount of characters from one string to another
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction) [edit]
une copie du tampon l'autre
Original:
copies one buffer to another
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction) [edit]
C documentation for strcpy

Web Proxy Viewer  |  New URL  |  Original Page