memcpy ()- Bytes de copia
Formato
#include <string.h>
void *memcpy(void *dest, const void *src, size_t count);Nivel de idioma
ANSI
De hebra segura
Sí
Descripción
La función memcpy() copia recuento bytes de src en dest. El comportamiento no está definido si la copia tiene lugar entre objetos que se solapan. La función memmove() permite copiar entre objetos que pueden solaparse.
Valor de retorno
La función memcpy() devuelve un puntero a dest.
Ejemplo
Este ejemplo copia el contenido de source en target.
#include <string.h>
#include <stdio.h>
#define MAX_LEN 80
char source[ MAX_LEN ] = "This is the source string";
char target[ MAX_LEN ] = "This is the target string";
int main(void)
{
printf( "Before memcpy, target is \"%s\"\n", target );
memcpy( target, source, sizeof(source));
printf( "After memcpy, target becomes \"%s\"\n", target );
}
/********************* Expected output: ************************
Before memcpy, target is "This is the target string"
After memcpy, target becomes "This is the source string"
*/