Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i am just a little confused on how to implement the .h file into this along side a cpp? the test file is the last

image text in transcribed
image text in transcribed
image text in transcribed
i am just a little confused on how to implement the .h file into this along side a cpp? the test file is the last picture i just dont know what to do with cpp and .h
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 C++ 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", "abo00001c") 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, myFind ("abc", "aabc000abc") should return 2 , since "abc" actually appears twice in "aabc000abe". 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"). 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 C++ 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", "abo00001c") 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, myFind ("abc", "aabc000abc") should return 2 , since "abc" actually appears twice in "aabc000abe". 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"). Hinclude \#include "LabProj3.h" using namespace std; I/ functions to test your program, DO NOT modify void testFind(const char* targetstr, const char*l substr) \& int res = myFind ( targetstr, substr ); if (res =){ string " "\" targetstr "\" endt; else \{ 3 II functions to test your program, DO NOT modify void testRemove(char* targetstr, const char* strToReesove) cout "The string before removing: " targetstr endt; int res = myRemove(targetstr, strToRemove); cout "The string before removing: "K targetstr \& endty if (res&=) f. in string " cout "String " "\"" strToRemove " "' " does not appear else \{ cout "The removal happens at location " res endl; 3 int main( ) testFind("abbbfd", "abc"); testFind ("Begining", "in"): testFind ("Mycomputer", "put"); testFind ("Download", "o"); testFind ("friendship", "ind"); char test1[15] = "Begining"; testremove(test1, "gin"); char test2[15] = "Computer"; testremove(test2, "put"); char test3[15] = "Download"; testremove(test3, "load")

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago