Wednesday, December 19, 2012

CONCATENATE TWO STRINGS PROGRAMME IN C++


#include<iostream.h>
#include<string.h>
void main()
{
char str1[50], str2[50], str3[100];
int count1, count2;
cout<<"ENTER THE FIRST STRING : ";
cin.getline(str1, 25);
cout<<"ENTER THE SECOND STRING : ";
cin.getline(str2, 25);
for(count1=0; str1[count1]!='\0'; count1++)
{
str3[count1]=str1[count1];
}
str3[count1]=' ';
count1++;
for(count2=0; str2[count2]!='\0'; count2++)
{
str3[count1+count2]=str2[count2];
}
str3[count1+count2]='\0';
cout<<"\nTHE NEW CONCATENATED STRING IS : \n\n";
cout<<str3;
}

No comments: