std::strncat
Defined in header <cstring> | | |
|---|---|---|
char *strncat( char *dest, const char *src, std::size_t count ); | | |
将字节字符串附加到src指向的字节字符串dest.最多count字符被复制。产生的字节字符串为空终止。
目标字节字符串必须有足够的空间来容纳两个字节字符串的内容。dest和src加上终止空字符,除非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...
例
二次
#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);
}二次
产出:
二次
Hello World! Go二次
另见
strcat | concatenates two strings (function) |
|---|---|
strcpy | copies one string to another (function) |
C.strncat文件
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

