C program to concatenate strings without using strcat

Concatenation means addition of two strings together. In C Programming language it can achieved using the strcat function in the string.h header file. We’ll see how to do it without using the strcat function.

 

#include <stdio.h>
#include<string.h>
int main()
{

char str[100],str1[100];
int count=0,i=0,j,n;
printf("enter string 1");
gets(str);
printf("enter string 2");
gets(str1);

for(i=0; str[i]!='\0'; ++i);
for(j=0;str1[j]!='\0';j++,i++){
str[i]=str1[j];

}

printf("cancatinated string is %s",str);

return 0;
}

 

 

Output