= memmove =
== Syntax == void *memmove(void *dest, void *src, int n); == Arguments == :dest ::The memory block to copy data to :src ::The memory block that data will be copied from :n ::The number of bytes to be copied == Return == Returns a pointer to the destination (dest) memory block. == Description == 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. == Comment == Be careful not to cause buffer overruns by copying more data into the destination memory block than it can hold. == Example == <code> // 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); </code> == See Also == |