memmove 的重复区域是指自身一部分吗?否则怎么会有重复?
我接触到的两个例子都是复制到自身,不知我的理解对不对?假如说a[3] = {1, 2, 3};与b[3] = {1, 2, 3};
应该不会有重复吧?不重复时复制用memcpy。是否有重复区域是不是看是不是不同的变量就行了?
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(void)
{
char s[]="Golden Global View";
memmove(s,s+7,strlen(s)+1-7);
printf("%s",s);
putchar('\n');
return 0;
}
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(void)
{
int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
memmove(a+2, a, 5*sizeof(int));
for(int i=0; i<10; i++)
{
printf("%d ", a[i]);
}
putchar('\n');
return 0;
}