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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started