Is it safe to use memcpy
in the following scenario, where one is copying data from larger index into a block to smaller index in the same block. For example:
char buf[100];
// fill in the data ...
memcpy(&buf[10], &buf[15], 10);
In the above scenario I don't care about data from location 10 - 19 and am fine if its overwritten. Is there some reason why this should be avoided and memmove
used instead?
EDIT: Sorry I have not communicated my intention properly, so lets say I have data from index 10 - 19 and data from index 15 - 24, I want to copy data from 15 - 24 over 10 - 19, and I don't care about data from 10 - 19, is it safe to us memcpy
even though they are overlapping?