APPENDING TWO STRINGS WITHOUT USING PRDEFINED STRING FUNCTIONS

#include<iostream>
#include<string>
using namespace std;
int main(){
string s1,s2;
int count=0;
cout<<"Manually appending two strings "<<endl;
cout<<"string s1 = ";
getline(cin,s1);
cout<<"string s2 = ";
getline(cin,s2);
int m=s1.size();
s1.resize(s2.size()+s1.size());

cout<<endl<<"after concatenation of string s1 and string s2"<<endl;
for(int x=m;x<s1.size();x++){
s1[x]=s2[count++];
}
cout<<" s1 = "<<s1<<endl;
}

Previous
Next Post »

Comments:

Disqus Shortname