Home C&C++函数库 c++ 语法 程序源码 Linux C库

strcat

函数   <cstring>

char * strcat ( char * destination, const char * source );

连接字符串

将源(source )字符串的副本追加到目标(destination)字符串。destination中的结束空字符被source中的第一个字符覆盖, 并且在由destination中的两个字符串形成的新字符串的末尾包含一个空字符。

source和destination不应重叠。

☲  参数


destination
指向目标数组的指针,该数组应该包含一个C字符串,并且要足够大,以包含连接的结果字符串。

source
要附加的C字符串。它不应该与destination重叠。

☉  返回值



返回 destination 。

☣  示例



/* strcat example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[80];
  strcpy (str,"these ");
  strcat (str,"strings ");
  strcat (str,"are ");
  strcat (str,"concatenated.");
  puts (str);
  return 0;
}

输出:
these strings are concatenated.

🍄  另请参阅



memcpy 拷贝内存块(function)
strncat 在字符串中追加字符(function)
strcpy 字符串考贝(function)

联系我们 免责声明 关于CandCplus 网站地图