This is an extended comment not an answer. The MSDN example is a poor one, confused by two similar source strings "The quick brown fox jumps over the lazy dog" and "The quick brown dog jumps over the lazy fox". My MS Visual C gives the correct result with memcpy()
when the source and destination do overlap, but as @PaulRoub wrote (now deleted), just because one compiler codes it correctly does not mean that another will.
#include <stdio.h>
#include <string.h>
int main()
{
char str [] = "abcdefghijklmnopqrstuvwxyz";
printf ("%s\n", str);
memcpy (str, str+1, 25); // copy down
printf ("%s\n", str);
memcpy (str+1, str, 25); // copy up
printf ("%s\n", str);
return 0;
}
Program output
abcdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyzz
bbcdefghijklmnopqrstuvwxyz