PROGRAM:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class dstring
{
private:
char *name;
int length;
public:
dstring()
{
name[0]=NULL;
}
dstring(int l)
{
length=l;
name=new char[l];
}
void input()
{
gets(name);
}
void display()
{
cout<<"the string is"<<endl;
puts(name);
}
void concat(dstring &s1,dstring &s2,dstring &s3)
{
s3.name=strcat(s1.name,s2.name);
cout<<"concatanated the string is: "<<s3.name;
}
};
void main()
{
clrscr();
dstring s1(10);
cout<<"enter the 1st string"<<endl;
s1.input();
s1.display();
dstring s2(10);
cout<<"enter the 2nd string"<<endl;
s2.input();
s2.display();
dstring s3(20);
s3.concat(s1,s2,s3);
getch();
}
No comments:
Post a Comment