Simulate the implementation of the Memmove function (consider memory overlap) #include <stdio.h> #include <assert.h> #include <string.h>void * memmove ( void * DST, const void * src, int count) {void * ret = Dst;assert (DST); assert (SRC); if (DST <= src | | (char *) DST >= ((char *) SRC + count) //Normal condition does not occur overlapping, from low to high {while (count--) {* (char *) DST = * (char *) SRC;DST = (char *) d St + 1;SRC = (char *) src + 1;}} else //overlap, from low to high {DST = (char *) DST + count-1;src = (char *) src + count-1;while (count--) {* (char *) DST = * (char *) SRC;DST = (char *) DST-1;SRC = (char *) src-1;}} return ret;} int main () {char p[] = "hello!"; Char *q = "World"; Memmove (P, Q,strlen (q) +1);p rintf ("%s\n", p); return 0;}
C language Simulation implements the Memmove function (consider memory overlap)