目录

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

描述 (Description)

C库函数char *strcat(char *dest, const char *src)char *strcat(char *dest, const char *src)指向的字符串追加到dest指向的字符串的末尾。

声明 (Declaration)

以下是strcat()函数的声明。

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

参数 (Parameters)

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

  • src - 这是要追加的字符串。 这不应与目的地重叠。

返回值 (Return Value)

此函数返回指向结果字符串dest的指针。

例子 (Example)

以下示例显示了strcat()函数的用法。

#include <stdio.h>
#include <string.h>
int main () {
   char src[50], dest[50];
   strcpy(src,  "This is source");
   strcpy(dest, "This is destination");
   strcat(dest, src);
   printf("Final destination string : |%s|", dest);
   return(0);
}

让我们编译并运行上面的程序,它将产生以下结果 -

Final destination string : |This is destinationThis is source|
↑回到顶部↑
WIKI教程 @2018