## Concate Two Strings

This operation is used to concate (combine) two string to form a new string.
In order to merge two strings, first we have to copy all the characters of first string into new string until NULL character is encountered in the first string. After copying all the characters of first string into new string we have to copy all the characters of second string into new string until NULL character is encountered in the second string.
Thus concatenation of two strings is similar to the copying of string.

## Algorithm to Concate two Strings

 Step 1: Length1 = 0 Length2 = 0 Step 2: Repeat step 3 while S1 [Length1] ≠ NULL Step 3: S3 [Length1] = S1 [Length1] Length1 = Length1+1 Step 4: Repeat step 5 while S2 [Length2] ≠ NULL Step 5: S3 [Length1] = S2[Length2] Length1 = Length1+1 Length2 = Length2+1 Step 6: S3 [Length1] = NULL

## Programto Concate two Strings

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char *s1,*s2,*s3;
void scat(char *s1,char *s2,char *s3);
clrscr();
puts("Enter string1:");
gets(s1);
puts("Enter string2:");
gets(s2);
scat(s1,s2,s3);
puts("New String is:");
puts(s3);
getch();
}
void scat(char *s1,char *s2,char *s3)
{
int length1=0;
int length2=0;
while(s1[length1]!='\0')
{
s3[length1]=s1[length1];
length1=length1+1;
}
while(s2[length2]!='\0')
{
s3[length1]=s2[length2];
length1=length1+1;
length2=length2+1;
}
s3[length1]='\0';
}