Hi,
is it correct(I mean "norm correct") to use "overlap" pointers as parameters of memcpy function from memory.h header?
Example:
1 2 3
|
//move 3 elements of the array one place to the right
int someArray[5];
memcpy(someArray + 1, someArray, sizeof(int) * 3);
| |
Is it correct?
I could try it of course (and I did it) but memory problems are disgusting as you surely know so I want to be sure about it.
Thank you!
Last edited on
No, if the source and destination buffers overlap you must use memmove instead.
Results are undefined due to the overlap. If the memory was in the same block but didn't overlap, then its perfectly fine.
It's exactly what I need to know.
Thank you so much!
Last edited on