Skip to content
Home » C program to concatenate two strings without using built-in functions

C program to concatenate two strings without using built-in functions

Below is the C program to add given two strings without using strcat() function.

#include <stdio.h>
int main(){
char a[50],b[50];
int i,j;
printf("Enter first string:");
fgets(a,50,stdin);
printf("Enter second string:");
fgets(b,50,stdin);
for(i=0;a[i]!='\0';i++);
i=i-1;
for(j=0;b[j]!='\0';j++){
a[i]=b[j];
i++;
}
a[i]='\0';
printf("String after joining:%s",a);
}

Output:

Enter first string:Similar geeks
Enter second string:is a platform to search codes.
String after joining:Similar geeks is a platform to search codes.