0% found this document useful (0 votes)
34 views1 page

STC

Uploaded by

Karthi Keyan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

STC

Uploaded by

Karthi Keyan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

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

h> class string { char *name; int length; public: string() { length=0; name=new char[length+1]; } string(char *s) { length=strlen(s); name=new char[length+1]; strcpy(name,s); } void concat(string &a,string &b) { length=a.length+b.length; delete name; name=new char[length+1]; strcpy(name,a.name); strcat(name,b.name); } void display() { cout<<name<<"\n"; } }; void main() { clrscr(); cout<<"\n\t\t CONCATENATION OF TWO STRINGS"; char s1[30],s2[30]; cout<<"\n\tEnter the two strings to be concatenated: "; cin>>s1>>s2; string name1(s1); string name2(s2); string name3; name3.concat(name1,name2); cout<<"\tThe first string is "; name1.display(); cout<<"\tThe second name is "; name2.display(); cout<<"\tThe concatenated string is "; name3.display(); getch(); }

You might also like