include iostream using namespace std void replace string first string

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
void replace(string &first, string &second) {
string tmp = first;
first = second;
second = tmp;
}
int main() {
string first, second;
cout << "Enter first string: " << endl;
getline(cin, first);
cout << "Enter second strings: " << endl;
getline(cin, second);
cout << "Entered strings: " << endl << "1st: " << first << endl << "2rd: " << second << endl;
replace(first, second);
cout << "Replaced strings: " << endl << "1st: " << first << endl << "2rd: " << second << endl;
return 0;
}