memmove ()- 复制字节数

格式

#include <string.h>
void *memmove(void *dest, const void *src, size_t count);

语言级别

ANSI

线程安全

描述

memmove() 函数将 srccount 字节复制到 dest。 此函数允许在可能重叠的对象之间进行复制,就像首先将 src 复制到临时数组一样。

返回值

memmove() 函数返回指向 dest的指针。

示例

此示例将单词 "shiny" 从位置 target + 2 复制到位置 target + 8
#include <string.h>
#include <stdio.h>
 
#define SIZE    21
 
char target[SIZE] = "a shiny white sphere";
 
int main( void )
{
  char * p = target + 8;  /* p points at the starting character
                          of the word we want to replace */
  char * source = target + 2; /* start of "shiny" */
 
  printf( "Before memmove, target is \"%s\"\n", target );
  memmove( p, source, 5 );
  printf( "After memmove, target becomes \"%s\"\n", target );
}
 
/*********************  Expected output:  ************************
 
Before memmove, target is "a shiny white sphere"
After memmove, target becomes "a shiny shiny sphere"
*/

相关信息