C strcat() Function Tutorial

The C programming language provides the strcat() function which is used to append or join strings or character arrays together. Two string or character arrays are provided to join where a second character array is added after the first character array.

strcat() Function Syntax

The strcat() function is syntax is like below. It accepts two parameters which are strings to join together.

char *strcat(char *str1, char *str)
  • *str1 and *str2 are strings where the *str2 is added after the *str1.

Join Two Strings

In the following example, we join strings “wise” and “tut” by using the strcat() function. The str1 is the joined string.

#include <stdio.h>
#include <string.h>

int main () {
   char str1[50], str2[50];

   strcpy(str1,  "wise");
   strcpy(str2, "tut");

   strcat(str1, str2);

   printf("%s", str1);

Leave a Comment