Espaces de noms
Variantes
Affichages
Actions

cpp/string/byte/strcpy : Différence entre versions

De cppreference.com
< cpp‎ | string‎ | byte
m (1 version : Translate from the English version)
(Fixed machine translation + added example - Traduction machine corrigée + exemple ajouté)
 
(2 révisions intermédiaires par un utilisateur sont masquées)
Ligne 1 : Ligne 1 :
{{tr_note}}
 
 
{{cpp/title| strcpy}}
 
{{cpp/title| strcpy}}
 
{{cpp/string/byte/navbar}}
 
{{cpp/string/byte/navbar}}
Ligne 6 : Ligne 5 :
 
}}
 
}}
  
{{tr|Copie la chaîne pointée par octet {{tt|src}} de chaîne d'octets, pointé par {{tt|dest}} .|Copies the byte string pointed to by {{tt|src}} to byte string, pointed to by {{tt|dest}}.}}
+
Copie la chaîne pointée par {{tt|src}} chaîne d'octets par {{tt|dest}}.
  
{{tr|Si les cordes se chevauchent, le comportement est indéfini .|If the strings overlap, the behavior is undefined.}}
+
les se chevauchent, |}}
  
 
===Paramètres===
 
===Paramètres===
{{param list begin}}
+
{{begin}}
{{param list item | dest |{{tr| pointeur vers la chaîne d'octets à copier| pointer to the byte string to copy to}}}}
+
{{| dest | pointeur la chaîne d'octets copier}}
{{param list item | src |{{tr| pointeur vers la chaîne d'octets terminée par NULL à copier| pointer to the null-terminated byte string to copy from}}}}
+
{{| src | pointeur la chaîne d'octets terminée par NULL à copier}}
{{param list end}}
+
{{end}}
  
 
===Retourne la valeur===
 
===Retourne la valeur===
Ligne 23 : Ligne 22 :
 
  |
 
  |
 
  | code=
 
  | code=
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
  | output=
 
  | output=
 +
 +
 
}}
 
}}
 +
  
 
===Voir aussi===
 
===Voir aussi===
{{dcl list begin}}
+
{{begin}}
{{dcl list template | cpp/string/byte/dcl list strncpy}}
+
{{| cpp/string/byte/strncpy}}
{{dcl list template | cpp/string/byte/dcl list memcpy}}
+
{{| cpp/string/byte/memcpy}}
{{dcl list see c | c/string/byte/strcpy}}
+
{{see c | c/string/byte/strcpy}}
{{dcl list end}}
+
{{end}}
 +
 
 +
 +
 +
 +
 +
 +
 +
 +
 +

Version actuelle en date du 6 novembre 2017 à 04:11

 
 
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