Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在阅读有关 memmove 的信息时,我读到它可以处理MEMORY OVERLAPS,但我无法了解两个字符串之间如何发生内存重叠以及该函数如何仍能正确复制内存块。
“内存重叠”不会自行发生。您可以为memmove函数提供重叠的内存区域。将两个指针放入同一个数组中,您很容易得到重叠的内存区域。
memmove
当然,您也可以通过联合轻松创建重叠对象。
目前尚不清楚问题的第二部分是什么意思(“此功能如何仍能正确复制内存块”)。您在哪里看到问题?
memmove(p+1, p, 42);
这需要从末尾开始移动字节。Memcpy() 把它弄得一团糟。