Social Icons

Tuesday, 18 February 2014

Program to concatenate two strings

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

void main()
{
clrscr();
char str1[20],str2[20],str3[40];
int i,j;
cout<<"\n Enter first string : ";
gets(str1);
cout<<"\n Enter second string : ";
gets(str2);

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

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

cout<<"\n\t After concatenate string is : "<<str3;
getch();
}


                                                        Output

No comments:

Post a Comment