void *memmove(void *dest, void *src, int n);
Returns a pointer to the destination (dest) memory block.
Despite the name, memmove copies data from one block of memory to another, up to the number of bytes given. If the memory blocks you are trying to copy overlap, it is better to use memmove instead of memcpy, as memmove uses a temporary buffer during the copy.
Be careful not to cause buffer overruns by copying more data into the destination memory block than it can hold.
// Allocate memory for the strings char *dest = calloc(10, 1); char *src = calloc(10, 1); // Store initial string values strcpy(dest, "oldstring"); strcpy(src, "newstring"); // Show before and after memmove Info("Before memmove: dest = %s, src = %s", dest, src); memmove(dest, src, 3); Info("After memmove: dest = %s, src = %s", dest, src);