Translate

Wednesday, 24 October 2012

Program for Concatenation of two strings

#include<iostream.h>
#include<conio.h>
#include<string.h>
class string
   {
     char st[20];
     public:
void input()
    {
cout<<"\nEnter the string=";
cin.getline(st,20);
    }
     string operator+(string s)
   {
     string temp;
     strcpy(temp.st,st);
     strcat(temp.st,s.st);
     return temp;
   }
     void output()
   {

     cout<<"\nThe string is="<<st;
   }
   };
void main()
      {
string s1,s2,s3;
clrscr();
s1.input();
s2.input();
s3=s1+s2;
s3.output();
getch();
      }

No comments:

Post a Comment