Skip to main content

Concat two strings without using Library or string function in C

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.
void main() 
	char string1[150], string2[100];
	int str1Len,str2Len;
	printf("\nEnter String 1 :\t");
	printf("\nEnter String 2 :\t");
	//identify entered string length using strlen function.
	// now using for loop we will add second string into first character by character.
	for (str2Len=0;string2[str2Len]!='\0';str1Len++,str2Len++)
	printf("\n\nConcated string is :\t%s", string1);



Enter String 1 :        Learning C Language

Enter String 2 :        Is Easy

Concated string is :    Learning C LanguageIs Easy