Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object: When it finds an occurrence of string2, it should replace it with string3 and save the result in a new string string4. For example,

Object:

When it finds an occurrence of string2, it should replace it with string3 and save the result in a new string string4.

For example, suppose the three strings have the following values:

String1: the dog jumped over the fence

String2: the

String3: that

The new string object will have the value that dog jumped over that fence.

Need help fixing my error in C++?

#include #include

using namespace std;

string replaceSubstring(string str1, string str2, string str3);

int main() { string one; string two; string three;

cout << "string1: " << endl; getline(cin,one); cout << "string2: " << endl; getline(cin,two); cout << "string3: " << endl; getline(cin,three);

// cout << one << endl; replaceSubstring(one, two, three); cout << replaceSubstring(one, two, three) << endl;

return 0; } string replaceSubstring(string str1, string str2, string str3) { string four; for (int x = 0; x < sizeof(str1); x++) { str1.find(str2); str1.replace(0, str2.length(), str3); } for (int x = 0; x < sizeof(str2); x++) { str2.find(str3); str2.replace(0, str3.length(), four); } return four; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago