Enter two string copy into third string

Write a program to enter two user define string and copy into third string.


Source Code:

#include<stdio.h>
#include<conio.h>
void main()
{
	char a[20],b[20],c[20];
	int i,j;
	clrscr();
	printf("Enter the First String:");
	gets(a);
	printf("Enter the Second String:");
	gets(b);
	for(i=0;a[i]!=NULL;i++)
	{
		c[i]=a[i];
	}
	c[i]=NULL;
	for(j=0;b[j]!=NULL;j++)
	{
		c[i+j]=b[j];
	}
	c[i+j]=NULL;
	printf("Given String is =%s",c);
	getch();
}

Output:

Enter the First String: Bhavesh
Enter the Second String: Jain

Given String is = Bhavesh Jain

Leave a Reply

Your email address will not be published. Required fields are marked *