Question: I need a C++ Program that has the following functions: 1. deleteText removes the first occurrence of the second c-string argument from the first c-string.

I need a C++ Program that has the following functions:

1. deleteText removes the first occurrence of the second c-string argument from the first c-string. Returns the index position in the first c-string where the second was found, otherwise -1 is returned.

2. reduceWhiteSpace replaces any contiguous white space of one character or more with a single space character ' '; there is no return value.

3. wordReport counts the words found in the first argument. The return value of the function is the number of words found. For this function, words are considered a sequence of one or more alphanumerics, separated by one or more non-alphanumeric characters.

4. countOccurrences searches for the text provided as the second c-string argument within the first function argument. The number of matches found is returned. e.g. countOccurrences("abcd", "bc") returns 1, and countOccurrences("aaaaaaa", "aaa") would return 2 (not 5),

5. countOccurrencesList searches the first c-string as for countOccurrences, except the second argument is an array of c-string pointers, and a third integer argument giving a count of the number of pointers in the array. A single value is returned which is the accumulated count of all occurrences of the words found in the first c-string.

6. replaceText replaces all occurrences of text found in the second argument, with the third argument (must be of equal or lesser size). Returns the number of replacements made. Returns 0 if the replacement c-string is longer than the second argument. Watch out: you could get an infinite loop if the search string is found within the replacement string, and you attempt to re-process from the start of the string.

Write the functions as described above. Make sure all required header files are included at the top of your program file.You may wish to write a main() program to test your function initially before proceeding with the following steps. If you do so, you must remove it or comment it out before continuing.Since you will not be submitting the main() function, You will be compiling your program by doing the following:Type your program code into Code::BlocksSave the linkable testdriver strMain.a to the same folder where your C++ program file is. (Right-click, then Save Link As ... or similar.)In Code::Blocks, go to the Settings menu, and select Compiler to bring up a dialog boxMake sure the Global Compiler Settings is selected on the left, then click on the Linker Settings tabJust below the Link libraries box, click the Add button, then navigate to where you saved strMain.a. Click Ok to close the library selection dialog box, and then Ok to close the Global Compiler Settings.You can now Compile and Run your program using the test driver. If your program does not compile, then you probably have not defined your function correctly, or forgot to include all appropriate header files.When running with the test driver, the program output will tell you if it is working correctly. Your program will be evaluated using the exact same test driver.Submit only the file containing your functions. You should not provide any test main() that you may have written for your own test purposes. When you submit your program on the class website, you should receive no compiler or linker errors.

You may use any function from the cctype library. From the cstring library you may use only strlen(), strstr(), and strncmp(). And, as for all assignments in this class, the C++ string class may not be used. The first argument to all functions that you will implement below is a c-string, and in most cases you will modify it, i.e. it is both a function input and output. All input-only parameters should be declared as constto indicate that the character array will not be modified. Note that word may be defined differently for various functions. For the purposes of matching, assume upper/lower case is significant, so Apple is not the same as apple.

Here is the test driver: https://drive.google.com/file/d/0B0Jl2I-W5UEPSDdyTFNtdDI2MWc/view?usp=sharing

Thank you!!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!