Espaces de noms
Variantes
Affichages
Actions

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

De cppreference.com
< cpp‎ | string‎ | byte
m (r2.7.3) (robot Ajoute : de, en, es, it, pt, ru Retire : fr)
m (Use {{lc}}. Update links. Various fixes.)
 
Ligne 15 : Ligne 15 :
  
 
===Paramètres===
 
===Paramètres===
{{param list begin}}
+
{{begin}}
{{param list item | dest |{{tr| pointeur vers le tableau de caractères à copier| pointer to the character array to copy to}}}}
+
{{| dest |{{tr| pointeur vers le tableau de caractères à copier| pointer to the character array to copy to}}}}
{{param list item | src |{{tr| pointeur vers la chaîne d'octets à copier| pointer to the byte string to copy from}}}}
+
{{| src |{{tr| pointeur vers la chaîne d'octets à copier| pointer to the byte string to copy from}}}}
{{param list item | count |{{tr| nombre maximum de caractères à copier| maximum number of characters to copy}}}}
+
{{| count |{{tr| nombre maximum de caractères à copier| maximum number of characters to copy}}}}
{{param list end}}
+
{{end}}
  
 
===Retourne la valeur===
 
===Retourne la valeur===
Ligne 52 : Ligne 52 :
  
 
===Voir aussi===
 
===Voir aussi===
{{dcl list begin}}
+
{{begin}}
{{dcl list template | cpp/string/byte/dcl list strcpy}}
+
{{| cpp/string/byte/strcpy}}
{{dcl list template | cpp/string/byte/dcl list memcpy}}
+
{{| cpp/string/byte/memcpy}}
{{dcl list see c | c/string/byte/strncpy}}
+
{{see c | c/string/byte/strncpy}}
{{dcl list end}}
+
{{end}}
  
 
[[de:cpp/string/byte/strncpy]]
 
[[de:cpp/string/byte/strncpy]]

Version actuelle en date du 2 juillet 2013 à 05:49

 
 
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 *strncpy( char *dest, const char *src, std::size_t count );
Des copies de la plupart des personnages count de la chaîne d'octets pointée par src (y compris le caractère nul final) au tableau de caractères pointée 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 chaîne entière a été copié, le tableau de caractères en résulte n'est pas terminée 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, après avoir copié le caractère NULL de fin de src, count n'est pas atteint, d'autres caractères nuls sont écrites dest jusqu'à ce que le total de caractères 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 indéfini .
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.

Sommaire

[modifier] Paramètres

dest -
pointeur vers le tableau de caractères à 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 chaîne 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 caractères à 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.

[modifier] Retourne la valeur

dest

[modifier] 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';
}

Résultat :

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

[modifier] Voir aussi

copie d'une chaîne à 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