On memcpy () function
It depends on how the compiler memcpy is implemented.

There are generally three types: copy from beginning to end or judge copy (equivalent to memmove).

I wrote a test program after yours.

Charles? message2[60]? =? ”abcdefghijklmnopqrstuvwxyz”;

Charles? tmp[60];

int? Master ()

{

strcpy(tmp,? Message 2);

printf("tmp=? \"%s\"\n ",? tmp);

memcpy(tmp+4,? tmp? +? 16,? 10);

printf("memcpy(tmp+4,? tmp? +? 16,? 10); & gt? tmp? =? \"%s\"\n ",? tmp);

strcpy(tmp,? Message 2);

memcpy(tmp+6,? tmp? +4,? 10);

printf("memcpy(tmp+6,? tmp? +4,? 10); & gt? tmp? =? \"%s\"\n ",? tmp);

strcpy(tmp,? Message 2);

memcpy(tmp+4,? tmp? +6,? 10);

printf("memcpy(tmp+4,? tmp? +6,? 10); & gt? tmp? =? \"%s\"\n ",? tmp);

The test results are as follows

tmp = " abcdefghijklmnopqrstuvwxyz "

memcpy(tmp+4,tmp + 16, 10); & gttmp = " abcdqrstuvwxyzopqrstuvwxyz "

memcpy(tmp+6,tmp +4, 10); & gttmp = " abcdefefefijijmnqrstuvwxyz "

memcpy(tmp+4,tmp +6, 10); & gttmp = " abcdghijklmnopopqrstuvwxyz "

Visible in memcpy(tmp+6, tmp +4,10); When there is superposition. Efef

It shows that my compiler (gcc) used head copy when doing memcpy, that is, copying from the starting address.

Memcpy(tmp+4, tmp +6, 10) if this is correct; If something goes wrong, it is a tail copy.

If nothing goes wrong, then after the judgment, smart copy is equivalent to memmove.