std:: wcscpy
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Null-terminated wide strings
| Functions | ||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||
| Array manipulation | ||||||||||||||||||||||||||
|
定义于头文件
<cwchar>
|
||
|
wchar_t
*
wcscpy
(
wchar_t
*
dest,
const
wchar_t
*
src
)
;
|
||
将指向的宽字符串 src (包括终止空宽字符)复制到由 dest 指向的宽字符数组中。
如果字符串重叠,则行为未定义。
目录 |
参数
| dest | - | 指向要复制到的宽字符数组的指针 |
| src | - | 指向要复制的以空字符结尾的宽字符串的指针 |
返回值
dest
示例
运行此代码
#include <clocale> #include <cwchar> #include <iostream> #include <memory> int main() { const wchar_t* src = L"犬 means dog"; // src[0] = L'狗'; // 无法修改字符串字面量 auto dst = std::make_unique<wchar_t[]>(std::wcslen(src) + 1); // +1 用于空字符 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
参阅
|
将指定数量的宽字符从一个字符串复制到另一个字符串
(函数) |
|
|
在两个不重叠的数组之间复制指定数量的宽字符
(函数) |
|
|
将一个字符串复制到另一个字符串
(函数) |
|
|
C 文档
for
wcscpy
|
|