std::wcscpy
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Text processing library
Regular expressions library (C++11)
Formatting library (C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
Null-terminated wide strings
(C++11)
(C++11)(C++11)
Defined in header
<cwchar>
wchar_t* wcscpy( wchar_t* dest, const wchar_t* src );
Copies the wide string pointed to by src (including the terminating null wide character) to wide character array pointed to by dest.
If the strings overlap, the behavior is undefined.
Contents
[edit] Parameters
dest
-
pointer to the wide character array to copy to
src
-
pointer to the null-terminated wide string to copy from
[edit] Return value
dest
[edit] Example
Run this code
#include <clocale> #include <cwchar> #include <iostream> #include <memory> int main() { const wchar_t* src = L"犬 means dog"; // src[0] = L'狗'; // can't modify string literal auto dst = std::make_unique <wchar_t[]>(std::wcslen (src) + 1); // +1 for the null std::wcscpy(dst.get(), src); dst[0] = L'狗'; std::setlocale (LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale ("")); std::wcout << src << '\n' << dst.get() << '\n'; }
Output:
犬 means dog 狗 means dog
[edit] See also
C documentation for wcscpy