#include <string.h>
void *memmove( void *to, const void *from, size_t count );
与 memcpy 相同,不同的是当 to 和 from 重叠,函数正常仍能工作。
#include <stdio.h> #include <string.h> int main () { char dest[] = "oldstring"; const char src[] = "newstring"; printf("Before memmove dest = %s, src = %s\n", dest, src); memmove(dest, src, 9); printf("After memmove dest = %s, src = %s\n", dest, src); return(0); }
输出结果:
Before memmove dest = oldstring, src = newstring After memmove dest = newstring, src = newstring