wcscpy() function in C++ with Examples

The wcscpy() function is defined in cwchar.h header file. The wcscpy() function is used to copy a wide character string from source to destination.

Syntax:

wchar_t *wcscpy(wchar_t *dest, const wchar_t *src);

Parameters: This method accepts the following two parameters:

  • dest: specifies the pointer to the destination array.
  • src: specifies the pointer to the source array.

Return Value: The wcscpy() function returns the modified destination.

Below program illustrate the above function:-

Example:-

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to demonstrate
// example of wcscpy() function.
  
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  
    // maximum length of the destination string
    wchar_t dest[40];
  
     // initialize the source string
    wchar_t src[]=L"A computer science portal for geeks";
  
// Print the source string
    wcout << L"Source: " << src << endl;
  
// Print the destination string
    wcout << L"Destination: " << dest << endl;
  
// Copy source to destination
    wcscpy(dest, src);
  
// Print the modified destination
    wcout << L"After modification, destination: " << dest;
  
    return 0;
}

chevron_right


Output:

Source: A computer science portal for geeks
Destination: 
After modification, destination: A computer science portal for geeks


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.