In this program we are accepting two strings from user using Gets. After that by calculating length of first string program is using for loop to append each character of second string to first string.
/* Program Name: Concatenate Two String without using in built-in function concat.
*/
#include<stdio.h>
#include<string.h>
void main()
{
char string1[150], string2[100];
int str1Len,str2Len;
printf("\nEnter String 1 :\t");
gets(string1);
printf("\nEnter String 2 :\t");
gets(string2);
//identify entered string length using strlen function.
str1Len=strlen(string1);
// now using for loop we will add second string into first character by character.
for (str2Len=0;string2[str2Len]!='\0';str1Len++,str2Len++)
string1[str1Len]=string2[str2Len];
string1[str1Len]='\0';
printf("\n\nConcated string is :\t%s", string1);
}
Output
Enter String 1 : Learning C Language
Enter String 2 : Is Easy
Concated string is : Learning C LanguageIs Easy