Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part II. Project 3 - Find and Remove in CStrings ( 20 points, submit your solution file online before the due date). Upload your file

image text in transcribed
image text in transcribed
image text in transcribed
Part II. Project 3 - Find and Remove in CStrings ( 20 points, submit your solution file online before the due date). Upload your file named LabProj3.cpp and LabProj3.h. The purpose of this programming assignment is to practice writing codes for c-strings. In this project, you are NOT AILOWED to use any Ct+ string class variable and its member functions. Your Tasks You will implement functions that allow the user to find or remove a sub-string in another given string (All strings are represented as c-strings). Below are the details of the functions you need to write in this project. int myFind(const char * targetStr, const char * subStr) : This function takes two parameters targetstr and substr of type char *. Each of them points to a c-string in memory. The function tries to find whether string substr appears in string targetstr. If subStr is not in targetstr, the function should return 0 ; For example, myFind("abc". "ab000001c") should return 0 , since "abc" cannot be found in "ab000001c". If substr is in targetstr, then the function returns the number of occurrences of substr in targetstr. For example, mylind( "abc", "aabc000abc") should return 2, since "abc" actually appears twice in "aaabe000abc". The second function is described below: int myRemove (char * targetstr, const char * strToRemove) This function takes two parameters: targetStr and strToRemove. Each of them points to a o-string in memory. The function will return 1 if strToRemove cannot be found in targetstr. Otherwise, the function will return the position of the first occurrence and remove the string pointed to by strToRemove in targetstr. For example, let targetstr points to some place in memory that stores the following c-string (which represents "Happy"). After the function call myRemove (targetStr, "PP"), the contents of the memory pointed by targetstr would become The string now becomes "Hay", the "pp" in "Happy" is removed. In addition, the function should return 2 in this case. Note that the '?' indicates the unknown remnants left over. The driver program (a program designed to test the program modules developed) LabProj3Test.cpp is provided on Canvas to test your functions in LabProj3.cpp. The header file LabProj3.h should contain the function prototype of the functions above that required you to write. Do forget to include the necessary preprocessing in the header file to avoid double inclusion in the user programs if any (in this case, the LabProj3Test.cpp program). \#include \#include "Labproj3. h " using namespace std; II functions to test your progran, DO NOT nodify void testFind (const char* targetstr, const char*i substr) \} int res = myFind(targetstr, substr): if ( res

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 Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago