You are on page 1of 2

String Concatenation

============================================
#include <conio.h>
#include <iostream.h>
void main()
{
clrscr();

char string1[20];
char string2[20];
char string3[40];

cout<<"\nEnter 1st String: ";


cin>>string1;
cout<<"\nEnter 2nd String: ";
cin>>string2;

int i=0;
int j=0;

while (1)
{
if (string1[i]!='\0')
string3[i]=string1[i];
else
break;
i++;
}
j=0;

while (1)
{
if (string2[j]!='\0')
string3[i]=string2[j];
else
{
string3[i]=string2[j];
break;
}
j++;
i++;
}
j=0;
cout<<"\nResultant String3: ";

while (1)
{
if (string3[j]!='\0')
cout<<string3[j];
else
break;
j++;
}

getch();
}

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006