Write a program to concatenate two strings without using strcat() function


#include<stdio.h> #include<conio.h> int main() { char name1[20]; char name2[20]; char name3[40]; int l1,l2,i,f=1,temp; printf("Enter first string value: \n"); gets(name1); l1=0; while(name1[l1]!='\0'){ l1++; } l2=0; printf("Enter second string value: \n"); gets(name2); while(name2[l2]!='\0'){ l2++; } //printf("First Stringlength is %d",l1); //printf("Second String length is %d",l2); i=0; temp=0; while(i name3[i]=name1[i]; temp++; i++; } i=0; while(i name3[temp]=name2[i]; temp++; i++; } printf("The concatenate string is :%s",name3); return 0; }

Output:-

Enter first string value: Code
Enter second string value: verb
The concatenate string is :Codeverb