函式
<cstring>

memmove

void * memmove ( void * destination, const void * source, size_t num );
移動記憶體塊
source 指向的位置的 num 位元組內容複製到 destination 指向的記憶體塊。複製過程如同使用了中間緩衝區,允許 destinationsource 重疊。

此函式不關心 sourcedestination 指標指向物件的底層型別;結果是資料的二進位制複製。

該函式不檢查 source 中的任何終止空字元——它總是複製 num 位元組。

為避免溢位,destinationsource 指標所指向的陣列大小應至少為 num 位元組。

引數

destination
指向要複製內容的 destination 陣列的指標,已強制轉換為型別為void*.
source
指向要複製資料的 source 的指標,已強制轉換為型別為const void*.
num
要複製的位元組數。
size_t 是一個無符號整數型別。

返回值

返回 destination

示例

1
2
3
4
5
6
7
8
9
10
11
/* memmove example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] = "memmove can be very useful......";
  memmove (str+20,str+15,11);
  puts (str);
  return 0;
}

輸出

memmove can be very very useful.


另見