Question: code should be written in c++ Objectives Familiarize the student with: working with multiple strings to combine into a single result. Scenario A common action

code should be written in c++

Objectives

Familiarize the student with:

  • working with multiple strings to combine into a single result.

Scenario

A common action when editing text is to replace an expression or word with yet another expression.

Write a program that will read three lines of text. In the last line read replace all occurrences of the expression in the first line with the expression in the second line.

Make sure that changing an expression to a similar expression will not cause your program any problems.

Example input John Mary John had a little lamb

Example output Mary had a little lamb

Example input difficult problems opportunities to grow A software engineer may encounter many difficult problems

Example output A software engineer may encounter many opportunities to grow

Example input Linux GNU Linux Some prefer Linux over Windows

Example output Some prefer GNU Linux over Windows

please add to the code below and comment

#include #include

int main() { std::string from; std::getline(std::cin, from);

std::string to; std::getline(std::cin, to);

std::string sentence; std::getline(std::cin, sentence);

// change all occurrences of 'from' into 'to' in the sentence

std::cout << sentence << " "; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!