C Standard Library

C <wchar.h> - wmemmove() Function



The C <wchar.h> wmemmove() function is used to copy num wide characters of memory block pointed to by source to the memory block pointed to by destination.

This method can be used even when the two memory blocks overlap. This is because copying takes place as if an intermediate buffer is created where the data are first copied to from source and then finally copied to destination.

Syntax

wchar_t* wmemmove (wchar_t* destination, const wchar_t* source, size_t num);

Parameters

destination Specify pointer to the first block of memory where the content is to be copied.
source Specify pointer to the second block of memory to copy from.
num Specify number of wide characters to copy.
size_t is an unsigned integer type.

Return Value

Returns destination

Example:

The example below shows the usage of wmemmove() function.

#include <stdio.h>
#include <wchar.h>
 
int main (){
  wchar_t str[50] = L"1234567890";

  //displaying content of str
  printf("str contains: %ls\n", str);

  //copying first 5 wide characters of str
  wmemmove(str + 5, str, 5);

  //displaying the result
  printf("str contains: %ls", str);

  return 0;
}

The output of the above code will be:

str contains: 1234567890
str contains: 1234512345

❮ C <wchar.h> Library