C++
字符串 | Strings

std::wcscpy

STD::wcscpy

Defined in header
wchar_t *wcscpy( wchar_t *dest, const wchar_t *src

复制由src%28包括将空宽字符%29终止为由dest...

如果字符串重叠,则行为未定义。

参数

dest-pointer to the wide character array to copy to
src-pointer to the null-terminated wide string to copy from

返回值

dest...

二次

#include <iostream> #include <cwchar> #include <memory> #include <clocale> 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'; }

二次

产出:

二次

犬 means dog 狗 means dog

二次

另见

wcsncpycopies a certain amount of wide characters from one string to another (function)
wmemcpycopies a certain amount of wide characters between two non-overlapping arrays (function)
strcpycopies one string to another (function)

c wcscpy文档

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/Wide/wcscpy