memmove内存有重叠,保证源字符串被覆盖之前,拷贝到目的川

memcpy不保证

最好用memmove

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>


int main() {
    char name1[30] = "hello guanxianseng";
    char name2[50];
    memmove(name2, name1, sizeof(name1));
    printf("name1:%s\n", name1);
    printf("name2:%s\n", name2); 

    memmove(name1, name1 + 5, 10);
    printf("name1:%s\n", name1);
    memcpy(name2, name2 + 5, 10);
    printf("name2:%s\n", name2);

    return 0;
}