void
*memmove(void *dest, const void *src, size_t n);
將n從一個記憶體位址複製n個資料到另一個位址,有點類似memcpy,但又有點不同
不同的地方在stack overflow有說明
memmove 可允許目標與來源位址相同
/*This file use to record string.h library use */
#include <string.h>
#include <stdio.h>
char SayBuf[10]="";//char buffer
char *hello="Hello\n";//show chars
int main()
{
printf("Before memmove\n");
printf("SayBuf:%s\n",SayBuf);
//目標,來源,長度
memmove(HelloBuf,HelloBuf,5);
printf("After memmove\n");
printf("SayBuf:%s\n",SayBuf);
printf("HelloBuf:%s\n",HelloBuf);
return 0;
}
可以看到在還沒有執行memmove之前,印出來的資料是空的,直到執行memmove之後才有資料

沒有留言:
發佈留言