std:: wmemset
From zh.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
*
wmemset
(
wchar_t
*
dest,
wchar_t
ch,
std::
size_t
count
)
;
|
||
将宽字符 ch 复制到由 dest 指向的宽字符数组的前 count 个宽字符中。
如果发生溢出,则行为是未定义的。
如果 count 为零,该函数不执行任何操作。
目录参数
返回值返回 dest 的副本。 注释此函数不区分区域设置,且不关注其写入的 wchar_t 对象值:空字符及无效宽字符同样会被写入。 示例
运行此代码
#include <clocale> #include <cwchar> #include <iostream> #include <locale> int main() { wchar_t ar[4] = {L'1', L'2', L'3', L'4'}; std::wmemset(ar, L'\U0001f34c', 2); // 将[12]替换为🍌香蕉 std::wmemset(ar + 2, L'蕉', 2); // 将[34]替换为蕉香蕉 std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << std::wstring(ar, 4) << '\n'; } 可能的输出: 🍌🍌蕉蕉 参阅
| |||||||||||||||||||