Parameter descriptions for memcpy
from the documentation:
void * memcpy ( void * destination, const void * source, size_t num );
destination
: Pointer to the destination array where the content is to be copied,
type-casted to a pointer of type void*.
source
: Pointer to the source of data to be copied, type-casted to a pointer of type const void*.
num
: Number of bytes to copy. size_t is an unsigned integral type.
memcpy
simply takes num
bytes starting from the address source
and copies them to memory starting at address destination
.
A pointer is a fixed length memory address, regardless of type. It does not matter whether the pointer is char *
(points to character data), int *
(points to integer data), or void *
(points to data of unknown type), it still just points to memory.
Because memcpy
copies an explicit number of bytes, the type of data being pointed to is irrelevant; it just need memory addresses to data.