std::strcpy
De cppreference.com
| Defined in header <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) | |
| 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) | |
| C documentation for strcpy
| |

