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

std::wcsncat

Defined in header <cwchar>

wchar_t *wcsncat( wchar_t *dest, const wchar_t *src, std::size_t count );

最多附加count所指向的宽字符串中的宽字符。src所指向的字符串的末尾。dest,如果复制空终止符,则停止。宽性src[0]的末尾替换空终止符。dest.空终止符总是追加在尾%28中,因此函数可以写入的最大宽字符数是count+129%。

如果目标数组不足以满足两个目标数组的内容,则该行为是未定义的。strdest以及终止空宽字符。

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

参数

dest

-

pointer to the null-terminated wide string to append to

src

-

pointer to the null-terminated wide string to copy from

count

-

maximum number of wide characters to copy

返回值

dest...

二次

代码语言:javascript
复制
#include <cwchar> 
#include <iostream>
#include <clocale>
 
int main(void) 
{
    wchar_t str[50] = L"Земля, прощай.";
    std::wcsncat(str, L" ", 1);
    std::wcsncat(str, L"В добрый путь.", 8); // only append the first 8 wide chars
 
    std::setlocale(LC_ALL, "en_US.utf8");
    std::wcout.imbue(std::locale("en_US.utf8"));
    std::wcout << str << '\n';
}

二次

可能的产出:

二次

代码语言:javascript
复制
Земля, прощай. В добрый

二次

另见

wcscat

appends a copy of one wide string to another (function)

strncat

concatenates a certain amount of characters of two strings (function)

wcscpy

copies one wide string to another (function)

c wcsncat文档

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

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

扫码关注腾讯云开发者

领取腾讯云代金券