function
<cwchar>

wcscpy

wchar_t* wcscpy (wchar_t* destination, const wchar_t* source);
Copy wide string
Copies the C wide string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point).

To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C wide string as source (including the terminating null character), and should not overlap in memory with source.

This is the wide character equivalent of strcpy (<cstring>).

Parameters

destination
Pointer to the destination array where the content is to be copied.
source
C wide string to be copied.

Return Value

destination is returned.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
/* wcscpy example */
#include <wchar.h>

int main ()
{
  wchar_t wcs1[]=L"Sample string";
  wchar_t wcs2[40];
  wchar_t wcs3[40];
  wcscpy (wcs2,wcs1);
  wcscpy (wcs3,L"copy successful");
  wprintf (L"str1: %ls\nstr2: %ls\nstr3: %ls\n",wcs1,wcs2,wcs3);
  return 0;
}


Output:

str1: Sample string
str2: Sample string
str3: copy successful

See also