Which function should be used to copy bytes between two memory regions that may overlap?
Correct answer D. memmove()
Explanation
memmove behaves as if the bytes were first copied to a temporary buffer, so it gives the correct result even when source and destination overlap, as when shifting array elements. memcpy has undefined behaviour for overlapping regions, although it may be slightly faster. strcpy is for null-terminated strings, and memset fills memory with one byte value rather than copying.
Answer checked How we write and check questions
Discussion