Write a program to append one string at the end of another string .Use append()function.
# include <iostream>
# include <string>
using namespace std;
int main()
{
string s1(“abcdefg”);
string s2(“hijklmn”);
cout <<“\n s1= “<<s1;
cout <<“\n after append ()”;
s1.append(s2);
cout <<“\n s1= “<<s1;
cout<<“\n”;
return 0;
}
OUTPUT
s1= abcdefg
after append ()
s1= abcdefghijklmn
Explanation
In the above program, two string objects s1 and s2 are declared and initialized with the strings
“abcdefg” and “hijklmn”. The s1 object invokes the member function append() and
s2 is passed as argument. The string s2 is added at the end of string s1.
Example 14.10
Write ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.