std::memset
De cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Defined in header <cstring>
|
||
void* memset( void* dest, int ch, std::size_t count ); |
||
Convierte el valor a
ch
unsigned char y lo copia en cada uno de los personajes count
primera del objeto apuntado por dest
. Si el objeto no es trivial-copiable (por ejemplo, escalar, matriz o una estructura C-compatible), el comportamiento no está definido. Si count
es mayor que el tamaño del objeto apuntado por dest
, el comportamiento es indefinido .Original:
Converts the value
ch
to unsigned char and copies it into each of the first count
characters of the object pointed to by dest
. If the object is not trivially-copyable (e.g., scalar, array, or a C-compatible struct), the behavior is undefined. If count
is greater than the size of the object pointed to by dest
, 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.
You can help to correct and verify the translation. Click here for instructions.
Contenido |
[editar] Parámetros
dest | - | puntero al objeto de llenar
Original: pointer to the object to fill The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ch | - | llenar byte
Original: fill byte 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 de bytes que llenar
Original: number of bytes to fill 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] Ejemplo
#include <iostream> #include <cstring> int main() { int a[20]; std::memset(a, 0, sizeof(a)); std::cout << "a[0] = " << a[0] << '\n'; }
Output:
a[0] = 0
[editar] Ver también
copia un tampón a otro 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. (función) | |
asigna un valor a una serie de elementos Original: assigns a value to a number of elements The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función de plantilla) | |
(C++11) |
checks if a type is trivially copyable (clase de plantilla) |
C documentation for memset
|