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

std::strcat

Defined in header <cstring>

char *strcat( char *dest, const char *src );

所指向的字符串的副本。src所指向的字符串的末尾。dest.角色src[0]的末尾替换空终止符。dest产生的字节字符串为空终止。

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

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

参数

dest

-

pointer to the null-terminated byte string to append to

src

-

pointer to the null-terminated byte string to copy from

返回值

dest...

二次

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

二次

产出:

二次

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

二次

另见

strncat

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

strcpy

copies one string to another (function)

c strcat文档

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

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

扫码关注腾讯云开发者

领取腾讯云代金券