Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
#include <wchar.h>
wchar_t *wcscpy(wchar_t * __restrict__string1, const wchar_t * __restrict__string2);
Copies the contents of string2 (including the ending wide NULL character) into string1. The wcscpy() function operates on NULL-terminated wide-character strings. The string arguments to this function must contain a wide NULL character marking the end of the string. Bounds checking is not performed.
The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.
wcscpy() returns the value of string1.
⁄* CELEBW08
This example copies the contents of source to destination using
wcscpy().
*⁄
#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t source[ SIZE ] = L"This is the source string";
wchar_t destination[ SIZE ] = L"And this is the destination string";
wchar_t * return_string;
printf( "destination is originally = \"%ls\"\n", destination );
return_string = wcscpy( destination, source );
printf( "After wcscpy, destination becomes \"%ls\"\n", destination );
}
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"