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

std::wmemset

Defined in header <cwchar>

wchar_t* wmemset( wchar_t* dest, wchar_t ch, std::size_t count );

复制宽字符ch进入第一个count所指向的宽字符数组的宽字符。dest...

如果发生溢出,则行为未定义。

如果count等于零,函数什么也不做。

参数

dest

-

pointer to the wide character array to fill

ch

-

fill wide character

count

-

number of wide characters to fill

返回值

返回dest...

注记

此函数不区分区域设置,也不注意wchar_t对象:NULL和无效的宽字符也被写入。

二次

代码语言:javascript
复制
#include <iostream>
#include <cwchar>
#include <clocale>
#include <locale>
 
int main()
{
    wchar_t ar[4] = {L'1', L'2', L'3', L'4'};
    std::wmemset(ar, L'\U0001f34c', 2); // replaces [12] with the ? bananas
    std::wmemset(ar+2, L'蕉', 2); // replaces [34] with the 蕉 bananas
 
    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout.imbue(std::locale("en_US.utf8"));
    std::wcout << std::wstring(ar, 4) << '\n';
}

二次

可能的产出:

二次

代码语言:javascript
复制
??蕉蕉

二次

另见

memset

fills a buffer with a character (function)

wmemcpy

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

fill_n

copy-assigns the given value to N elements in a range (function template)

c wmemset文档

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

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

扫码关注腾讯云开发者

领取腾讯云代金券