Espaces de noms
Variantes
Affichages
Actions

std::strcpy

De cppreference.com
< cpp‎ | string‎ | byte
 
 
Bibliothèque de chaînes de caractères
Chaînes à zéro 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 chaînes d'octets
Chaines multi-octets
Les chaînes é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
 
Chaînes d'octets à zéro 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 caractère
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 numériques
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 chaînes
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 chaîne
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 mémoire
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
 
Déclaré dans l'en-tête <cstring>
char *strcpy( char *dest, const char *src );

Copie (avec le caractère NULL de fin) la chaîne d'octets pointée par src vers la chaîne d'octets pointée par dest.

Le comportement est indéfini si les chaînes se chevauchent, ou si dest n'est pas assez grand.

Sommaire

[modifier] Paramètres

dest - pointeur sur la chaîne d'octets vers laquelle copier
src - pointeur sur la chaîne d'octets terminée par NULL à copier

[modifier] Retourne la valeur

dest

[modifier] Exemple

#include <iostream>
#include <cstring>
#include <memory>
 
int main()
{
    const char* src = "Casser un test.";
//  src[0] = 'P'; // Impossible de modifier une chaîne 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';
}

Résultat :

Casser un test.
Passer un test.


[modifier] Voir aussi

copie d'un certain nombre de caractères d'une chaîne à 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