Question: Create a program that accepts keyboard input of a C - string and a search character. The C - string will be a dynamic array
Create a program that accepts keyboard input of a Cstring and a search character.
The Cstring will be a dynamic array that holds up to characters plus the ending character.
Write this function:
char findLastOccurrencechar char
where the first parameter is a Cstring and the second is the character to find in the Cstring. The function returns a pointer to the last occurrence of the character to find, or it returns nullptr.
Your program may only use when creating and destroying the dynamic Cstring.
No or indexes are allowed in findLastOccurrence Skipping using pointers to process the dynamic array will be a cheating violation.
Prove that the findLastOccurrence function is correct by executing your solution for the first four tests. Display the characters in the input Cstring that starts at the return value from the function using this format:
Ex:
Enter a string up to characters: Hidy howdy hi ho Enter a character to find: i The last occurrence of i begins the substring of i ho
Ex:
Enter a string up to characters: My dog has lots of fleas. Enter a character to find: F F does not appear in My dog has lots of fleas."
Ex:
Enter a string up to characters: Abracadabra Enter a character to find: a The last occurrence of a begins the substring of a
Recall that cout and along with a pointer to an element of a Cstring char array correctly displays all the characters up to the ending
The Unit Tests and will require that you include the header file in your solution, and then execute your program again.
Draw lots of pictures, with arrows representing the pointer variables, as you solve this problem. No one can keep track of the pointers arrows without drawing pictures.
here is c code needs to be completed.
missing header files
your completed program must pass tests to without including in your answer.
unit tests and require that you include only for these tests.
a fully correct solution will pass all tests without using anything from the
header file.
using namespace std;
other function definition
int main
use these constants in your display of the final results
const char DOUBLEQUOTES ;
const char SINGLEQUOTE ;
create a dynamic Cstring that can up to characters before the ending null character
process the dynamic Cstring
destroy the dynamic Cstring to avoid memory leaks
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
