Skip to content
Related Articles

Related Articles

Improve Article

wmemmove() function in c++

  • Difficulty Level : Basic
  • Last Updated : 14 Oct, 2020

The wmemmove() function is defined in cwchar.h header file. The wmemmove() function copies a specified number of wide characters from source to the destination.

wchar_t* wmemmove(wchar_t* dest, const wchar_t* src, size_t n);

Parameters: This method accepts the following parameters: 

  • dest: specifies the pointer to the destination array.
  • src specifies the pointer to the source array.
  • n: Number of wide characters to copy from src to dest.

Returns: The wmemmove() function returns the modified destination.
The below program illustrate the above function:-


// c++ program to demonstrate
// example of wmemmove() function.
#include <bits/stdc++.h>
using namespace std;
int main()
    // Maximum length of the destination string
    wchar_t* dest_buf=L"A computer
                     science portal for geeks";
    wchar_t dest[wcslen(dest_buf)+1];
    // Maximum length of the source string
    wchar_t* src_buf=L"geeksforgeeks";
    wchar_t src[wcslen(src_buf)+1];
    // Initialize the destination string
    wprintf(L"Destination: %ls\n", dest);
    // Initialize the source string
    wcscpy(src,src_buf );
    wprintf(L"Source: %ls\n", src);
    wmemmove(dest+2, src+3, 5);
    wprintf(L"After modication, destinstion:
                                   %ls\n", dest);
    return 0;
Destination: A computer science portal for geeks
Source: geeksforgeeks
After modication, destinstion: A ksforter science portal for geeks


Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :