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 that 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 a address pointed by dst
pointer.
I am not able to understand the following important statement regarding memcpy()
:
- When using
memcpy()
, memory address should not overlap, if it overlaps then the memcpy()
is undefined.
Another query is:
Is the value passed to third argument of the function i.e size_t n
is always an integer value?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…