Espaços nominais
Variantes
Acções

std::strncpy

Da cppreference.com
< cpp‎ | string‎ | byte

 
 
Biblioteca cordas
Strings terminadas
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.
Cadeias de bytes
Multibyte cordas
Cordas de largura
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.
 
Cordas de terminação nula de bytes
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manipulação personagem
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.
Conversões para formatos numéricos
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.
Manipulação de cadeia
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.
strncpy
Exame String
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.
Manipulação de memória
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.
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <cstring>
char*strncpy(char*dest, constchar*src, std::size_t count );
Cópias de personagens mais count da cadeia de bytes apontado por src (incluindo o caractere nulo de terminação) a matriz de caracteres apontada por 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.
Se count for atingido antes da src cadeia inteira foi copiado, a matriz de caracteres resultante não é nulo terminada.
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.
Se, depois de copiar o caractere nulo de terminação de src, count não for alcançado, outros caracteres nulos são escritos para dest até que o total de caracteres count ter sido escrita.
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.
Se as cordas se sobrepõem, o comportamento é indefinido.
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.

Índice

[editar]Parâmetros

dest -
ponteiro para a matriz de caracteres para copiar
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 -
ponteiro para o byte string para copiar
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 -
número máximo de caracteres a serem copiados
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.

[editar]Valor de retorno

dest

[editar]Exemplo

#include <iostream>#include <cstring>   int main(){constchar* 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';}

Saída:

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

[editar]Veja também

copia uma string para outra
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.

(função)[edit]
copia um buffer para outro
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.

(função)[edit]
Documentação C para strncpy
close