I am trying to understand the function memcpy()
which is defined in the C library <string.h>
Syntax: void *memcpy(void*dst,const void*src,size_t n);
I know this function is used to copy the contents of the memory pointed by pointer src
to the location pointed by the dst
pointer and return the address pointed by dst
.
I am not able to understand the following important statement regarding memcpy()
:
- When using
memcpy()
, the memory address should not overlap, if it overlaps then thememcpy()
is undefined.
Another query is:
Is the value passed to the third argument of the function i.e size_t n
always an integer value?