Defined in header <wchar.h> | ||
---|---|---|
(1) | ||
wchar_t *wcscpy( wchar_t *dest, const wchar_t *src ); | (since C95) (until C99) | |
wchar_t *wcscpy( wchar_t *restrict dest, const wchar_t *restrict src ); | (since C99) | |
errno_t wcscpy_s( wchar_t *restrict dest, rsize_t destsz, const wchar_t *restrict src ); | (2) | (since C11) |
src
(including the terminating null wide character) to wide character array pointed to by dest
. The behavior is undefined if the dest
array is not large enough. The behavior is undefined if the strings overlap.src
or dest
is a null pointer destsz
is zero or greater than RSIZE_MAX / sizeof(wchar_t)
destsz
is less or equal wcsnlen_s(src, destsz)
, in other words, truncation would occur wcscpy_s
is only guaranteed to be available if __STDC_LIB_EXT1__
is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__
to the integer constant 1
before including wchar.h
.dest | - | pointer to the wide character array to copy to |
src | - | pointer to the null-terminated wide string to copy from |
destsz | - | maximum number of characters to write, typically the size of the destination buffer |
dest
L'\0'
to dest[0]
(unless dest
is a null pointer or destsz
is zero or greater than RMAX_SIZE / sizeof(wchar_t)
).#include <wchar.h> #include <stdio.h> #include <locale.h> int main(void) { wchar_t *src = L"犬 means dog"; // src[0] = L'狗' ; // this would be undefined behavior wchar_t dst[wcslen(src) + 1]; // +1 to accommodate for the null terminator wcscpy(dst, src); dst[0] = L'狗'; // OK setlocale(LC_ALL, "en_US.utf8"); printf("src = %ls\ndst = %ls\n", src, dst); }
Output:
src = 犬 means dog dst = 狗 means dog
(C95)(C11) | copies a certain amount of wide characters from one string to another (function) |
(C95)(C11) | copies a certain amount of wide characters between two non-overlapping arrays (function) |
(C11) | copies one string to another (function) |
C++ documentation for wcscpy |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/c/string/wide/wcscpy