C++ Program to concatenate two strings

C++ Program to concatenate two strings

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

void main()
{
clrscr();
char str1[30],str2[30],str3[60];
int i,j;
cout<<“Enter first string:”;
gets(str1);
cout<<“nEnter second string:”;
gets(str2);

for(i=0;str1[i]!=’’;++i)
str3[i]=str1[i];

for(j=0;str2[j]!=’’;++j)
str3[i+j]=str2[j];
str3[i+j]=’’;

cout<<“nThe concatenate string is “<<str3;
getch();
}

One thought on “C++ Program to concatenate two strings

Leave a Reply

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