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

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

std::strncpy

De cppreference.com

<metanoindex/>

 
 
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 *strncpy( char *dest, const char *src, std::size_t count );
Des copies de la plupart des personnages count de la chane d'octets pointe par src (y compris le caractre nul final) au tableau de caractres pointe par dest .
Original:
Copies at most count characters of the byte string pointed to by src (including the terminating null character) to character array pointed to by dest.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si count est atteint avant la src chane entire a t copi, le tableau de caractres en rsulte n'est pas termine par NULL .
Original:
If count is reached before the entire string src was copied, the resulting character array is not null-terminated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si, aprs avoir copi le caractre NULL de fin de src, count n'est pas atteint, d'autres caractres nuls sont crites dest jusqu' ce que le total de caractres count ont t crit .
Original:
If, after copying the terminating null character from src, count is not reached, additional null characters are written to dest until the total of count characters have been written.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si les cordes se chevauchent, le comportement est indfini .
Original:
If the strings overlap, the behavior is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Paramtres

dest -
pointeur vers le tableau de caractres copier
Original:
pointer to the character array to copy to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
src -
pointeur vers la chane d'octets copier
Original:
pointer to the byte string to copy from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
count -
nombre maximum de caractres copier
Original:
maximum number of characters to copy
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Retourne la valeur

dest

Exemple

#include <iostream>
#include <cstring>

int main()
{
    const char* src = "hi";
    char dest[6] = {'a', 'b', 'c', 'd', 'e', 'f'};;
    std::strncpy(dest, src, 5);

    std::cout << "The contents of dest are: ";
    for (char c : dest) {
        if (c) {
            std::cout << c << ' ';
        } else {
            std::cout << "\\0" << ' ';
        }
    }
    std::cout << '\n';
}

Rsultat :

The contents of dest are: h i \0 \0 \0 f

Voir aussi

copie d'une chane l'autre
Original:
copies 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 strncpy

Web Proxy Viewer  |  New URL  |  Original Page