首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::wcscpy

Defined in header <cwchar>

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...

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
犬 means dog
狗 means dog

二次

另见

wcsncpy

copies a certain amount of wide characters from one string to another (function)

wmemcpy

copies a certain amount of wide characters between two non-overlapping arrays (function)

strcpy

copies one string to another (function)

c wcscpy文档

代码语言:txt
复制
 © cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券