If I have an array of elements, is it okay to use memcpy to copy some data from the back of an array to the front part
Presented in code:
int a[5] = {1,2,3,4,5};
memcpy(a, a + 2, 3 * sizeof(int));
As you can see some parts are copied to the other place in the front and then overwritten later (number 3).
Array after memcpy is {3, 4, 5, 4, 5}, but does this invoke undefined behaviour or is it completely valid to do such thing? I'm using c++ and VS2017 compiler.
memove()is for.man memcpy: "The memory areas must not overlap."std::copy.