在发生overlap的情况下,memcpy在不同的平台是有差别的
这是例子
#include "stdio.h" char str1[9] = "aabbccdd"; int main( void ) { printf("The string: %s\n", str1); memcpy(str1 + 2, str1, 6); printf("New string: %s\n", str1); strcpy(str1, "aabbccdd"); // reset string printf("The string: %s\n", str1); memmove(str1 + 2, str1, 6); printf("New string: %s\n", str1); }
在不同的Target上,memcpy的行为不同,memmove是一致的
所以memcpy的时候要注意这个问题
gcc on Ubuntu: The string: aabbccdd New string: aaaaaabb The string: aabbccdd New string: aaaabbcc Some ARM Target The string: aabbccdd New string: aaaabbbb The string: aabbccdd New string: aaaabbcc
来源:https://www.cnblogs.com/shinedream/p/12574010.html