C strcat()

The strcat() function is defined in the string.h header file. It helps to concatenate two strings by appending the string pointed by src to the destination string pointed by dest. 

char *strcat(char *dest, const char *src); #where dest and src should be strings


strcat() Parameters: 

The strcat() function takes two parameters. The size of the destination string should be large enough to store the resultant string if not it will raise segmentation fault error.

Parameter Description Required / Optional
dest Pointer to the destination array contains the concatenated resulting string Required
src This is the string to be appended Required

strcat() Return Value

The function returns a pointer to the resulting destination string. 

Input Return Value
success pointer to destination string

Examples of strcat() 

Example 1: Working of strcat() function in C?

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

int main()
   char src[40], dest[40];

   strcpy(src,  "Source is:");
   strcpy(dest, "Destination is:");

   strcat(dest, src);

   printf("Final destination string : |%s|", dest);



Final destination string : |Destination is Source is|

Example 2: How strcat() works in C?

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

int main (){

   char string1[100] = "This is ", string2[] = "learnetutorials.com";

   // the resultant string is stored in string1.
   strcat(string1, string2);

   return 0;


This is learnetutorials.com