Program to Concatenate Two Strings without using strcat()

Whenever we are asked to write a program to concatenate two strings, we make use of inbuilt function- strcat (). Obviously, it is the easy method and we can use that. But sometimes, we are asked not to use the strcat (). This program helps to concatenate two strings without using strcat()

 #include <stdio.h>

#include <conio.h>

#include <string.h>

 void main()


 char string1[30], string2[20];

 int i, length=0, temp;

  printf(“Enter the 1st String : \n”);


 printf(“\nEnter the 2nd String : \n”);


  for(i=0; string1[i]!=’\0′; i++)


 temp = length;

  for(i=0; string2[i]!=’\0′; i++)


 string1[temp] = string2[i];



 string1[temp] = ‘\0’;

  printf(“\n The final concatenated string is:\n”);




Mohit Arora
Follow me