memmove

Learned about this through Ryan, Shaheer’s friend.

https://cplusplus.com/reference/cstring/memmove/

Basically, the difference with memmove is that it does extra work to handle for cases where there is overlapping memory addresses.

Source:

he memory in memcpy cannot overlap or you risk undefined behaviour, while the memory in memmove can overlap.

char a[16];
char b[16];
 
memcpy(a,b,16);           // Valid.
memmove(a,b,16);          // Also valid, but slower than memcpy.
memcpy(&a[0], &a[1],10);  // Not valid since it overlaps.
memmove(&a[0], &a[1],10); // Valid.