Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write c++ code for the following programs using c++ strings YOU CANNOT USE ANY break, continue or goto statement IN This QUESTIONS PLEASE DO USE

image text in transcribed

Write c++ code for the following programs using c++ strings

image text in transcribed

YOU CANNOT USE ANY break, continue or goto statement IN This QUESTIONS PLEASE DO USE THE HELPER FILES PROVIDED BY ME FOR QUESTION NUMBER 1

Note: You cannot use Extra Arrays in this function but you can create helper functions if required.

Question 1: Implement the find and replace function similar to MS word. You have to find the first matching instance of the findstring' with the replacestring' in the 'mainstring For example: mainString: "I love computing. It is so much fun" replaceString: "Lahore" mainString changes to: "I love Lahore. It is so much fun" Another example: mainString: "I love computing. It is so much fun" findString: "fun" replaceString: "going to the library" mainString changes to: "I love Lahore. It is so much going to the library HELPER FUNCTIONS You Cannot use extra Arrays in these functions //find the length of the string int stringLength(char strn) //find if a substring is present in the nain string and return its starting index if found /Freturn-1 otherwise int findString(char mainStrl], char subStr[l) /freplace a substring which is bigger than the findStr void replacewithBiggerstring(char mainStr), char replaceStr,int index,int lengthFindStr); //replace a substring which is snaller than the findStr void replacewithSmallerstring(char mainStr), char replaceStr,int index,int lengthFindStr); /freplace with a string of same size as find string void replacewithEqualString(char nainStr[], char replaceStr[],int index) /ain find and replace function...return the index at which find and replace were made /freturn -1 if findStr not found and no replacements were nade int findReplace(char mainstr[),char findStrl,char replaceStrl) void testFindReplace) char nainstr[200] = "C++ is so great and fun. char findstr[58)- "great and" char replacestr1(58] .nice. ; char replacestr2[S]"ice and simple and"; findReplace(mainstr,findstr,replacestri); cout

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions