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

std::strncat

Defined in header <cstring>

char *strncat( char *dest, const char *src, std::size_t count );

将字节字符串附加到src指向的字节字符串dest.最多count字符被复制。产生的字节字符串为空终止。

目标字节字符串必须有足够的空间来容纳两个字节字符串的内容。destsrc加上终止空字符,除非src仅限于count...

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

参数

dest

-

pointer to the null-terminated byte string to append to

src

-

pointer to the null-terminated byte string to copy from

count

-

maximum number of characters to copy

返回值

dest...

二次

代码语言:javascript
复制
#include <cstring>
#include <cstdio>
 
int main() 
{
    char str[50] = "Hello ";
    char str2[50] = "World!";
    std::strcat(str, str2);
    std::strncat(str, " Goodbye World!", 3);
    std::puts(str);
}

二次

产出:

二次

代码语言:javascript
复制
Hello World! Go

二次

另见

strcat

concatenates two strings (function)

strcpy

copies one string to another (function)

C.strncat文件

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

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

扫码关注腾讯云开发者

领取腾讯云代金券