New Generic pointer that can point to any data type
1st Parameter
Pointer to the destination memory block where the content is to be copied.
2nd Parameter Type : const void *
A pointer to a constant memory location of unspecified type. The pointed-to data cannot be modified through this pointer.
2nd Parameter
Pointer to the source memory block from which the content will be copied.
3rd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
3rd Parameter
The number of bytes to copy from the source to the destination.
Read more about parameters of memcpy in parameters section
The memcpyfunction in C language Copies one block of memory to another.
The memcpy function copies n bytes from the object pointed to by src to the object pointed to by dest. The behavior is undefined if the objects overlap. The function does not check for any terminating null character; it always copies exactly n bytes.
The memcpyfunction takes 3
parameters:
•
void * `destination`: Pointer to the destination memory block where the content is to be copied.
•
const void * `source`: Pointer to the source memory block from which the content will be copied.
•
size_t `num`: The number of bytes to copy from the source to the destination.
Copies `num` bytes from the memory block pointed to by `source` to the memory block pointed to by `destination`. The memory areas must not overlap, as the behavior is undefined in that case. Returns a pointer to the `destination` memory block.
The memcpy function return value :
Returns a pointer to dest
Output
This example demonstrates basic usage of memcpy to copy a string.