CKTIS / C
wcscpy — copy a wide string
wcscpy copies a wchar_t string including its terminator. The destination must be large enough, and the copied regions must not overlap.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <wchar.h>
wchar_t *wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2);wcscpy, declared in <wchar.h>, copies the string from s2 to s1, including the terminating L'\0'. It returns s1, not the copied length.
The destination must be writable and hold at least wcslen(s2) + 1 elements of wchar_t, not bytes. The source must be terminated. An undersized buffer, invalid pointers, or overlapping copied regions cause undefined behavior.
The function accepts no buffer capacity and performs no encoding conversion. The example reserves room for the terminator; it prints the length and the result of comparing the returned pointer with dst.
Examples
#include <stdio.h>
#include <wchar.h>
int main(void)
{
const wchar_t src[] = L"Hello";
wchar_t dst[sizeof src / sizeof src[0]];
wchar_t *result = wcscpy(dst, src);
printf("length=%zu, same_pointer=%d\n",
wcslen(dst), result == dst);
return 0;
}Result
length=5, same_pointer=1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.