wchar_t* wcscpy( wchar_t* dest, const wchar_t* src );
(since C95)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 );
1) Copies the wide string pointed to by 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.
2)Same as
(1), except that it may clobber the rest of the destination array with unspecified values and that the following errors are detected at runtime and call the currently installed
constraint handlerfunction:
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>.
1) returns a copy of dest
2) returns zero on success, returns non-zero on error. Also, on error, writes L'\0' to dest[0] (unless dest is a null pointer or destsz is zero or greater than RMAX_SIZE / sizeof(wchar_t)).
[edit] Example#include <locale.h> #include <stdio.h> #include <wchar.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 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[edit] References
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4