C String Functions - C strcat

Concatenates two strings.

char *strcat(char *str1 , const char *str2 );

Appends the string str2 to the end of the string str1.

The terminating null character of str1 is overwritten.

Copying stops once the terminating null character of str2 is copied.

If overlapping occurs, the result is undefined.

The argument str1 is returned.


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


This function has the following parameter.

Pointer to the destination array.
C string to be appended.


destination is returned.


#include <stdio.h>
#include <string.h>
/*  ww  w .  ja  va  2 s.c  o  m*/
int main (){
  char str[80];
  strcpy (str,"these ");
  strcat (str,"strings ");
  strcat (str,"are ");
  strcat (str,"concatenated.");
  puts (str);
  return 0;


The code above generates the following result.

Example 2

#include <string.h> 
#include <stdio.h>
#include <stdlib.h>
 /*  w w  w.  j a  v  a 2  s .  c  o  m*/
int main(void) {
    char str[50] = "Hello ";
    char str2[50] = "World!";
    strcat(str, str2);
    strcat(str, " ...");
    strcat(str, " Goodbye World!");


The code above generates the following result.