Concatenate two given string


Levels of difficulty: / perform operation:

C a program to concatenate two given string without using the library function strcat().

C Program

#include <stdio.h>
#include <conio.h>
void strconc(char *,char *);
char *s3;
void main()
{
	char *str1,*str2;
	clrscr();
	printf("\nENTER THE FIRST STRING: ");
	gets(str1);
	printf("\nENTER THE SECOND STRING: ");
	gets(str2);
	strconc(str1,str2);
	printf("\nTHE NEW STRING IS: %s",s3);
	getch();
}
void strconc(char *s1,char *s2)
{
	int ls1,ls2,i;
	ls1=strlen(s1);
	ls2=strlen(s2);
	s3=s1;
	for(i=0;i<ls2;i++)
	{
		s3[ls1++]=s2[i];
	}
	s3[ls1++]=NULL;
}


Output