Question: I need a single c++ program that has functions that do and are called the following AND has to work with the linked test driver
I need a single c++ program that has functions that do and are called the following AND has to work with the linked test driver in codeblocks.
Here is the test driver: https://drive.google.com/file/d/0B0Jl2I-W5UEPSDdyTFNtdDI2MWc/view?usp=sharing
Here are the functions and what they should do::
1. reduceWhiteSpace replaces any contiguous white space of one character or more with a single space character ' '; there is no return value.
2. 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),
3. 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.
4. 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.
5. reverseWordText reverses the words. This function calls reduceWhiteSpace before reversing words. For this function, words are defined as any contiguous sequence of non-white space characters. e.g. "Don't do it" becomes "it do Don't"; there is no return value.
Some other requirements:
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.
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
