Question: #include #include #include using namespace std; void reverse(char* front, char* rear); // Precondition: The front and rear are pointing to the front // and rear
#include#include #include using namespace std; void reverse(char* front, char* rear); // Precondition: The front and rear are pointing to the front // and rear of a C-string, respectively // Postcondition: The C-string is reversed string* addEntry(string* dynamiccArray, int& size, string newEntry); // Precondition: dynamicArray point to a array of strings with give size, // newEntry is a string // Postcondition: A new dynamic array is created, which is one larger than // dynamicArray All elements from dynamicArray are copied to // new array, the new entry is added to new array, the size // is increased, the dynamicArray is deleted, new dynamic // array is returned. string* deleteEntry(string* dynamicArray, int& size, string entryToDelete); // Precondition: dynamicArray point to a array of strings with give size, // newEntry is a string // Postcondition: The function should search dynamicArray for entryToDelete. // If not found, the request should be ignored and the // unmodified dynamicArray returned. If found, create a new // dynamic array one element smaller than dynamicArray. Copy // all element except entryToDelete into the new array, delete // dynamicArray, decrement size, and return the new dynamic // array void print(const string* dynamicArray, int size); // Precondition: dynamicArray point to a array of strings with give size, // Postcondition: The elements in dynamic array will be print out. One // element per line forllowed by its index int main() { // write code to test reverse function. // make sure that you test it on at least two strings // one string has even length, another string has odd length // write code to test add entry and delete entry function // you may watch video notes to get idea for this part return 0; } void reverse(char* front, char* rear) { // you implement this. Please read Programming Project 4 on page 535 } string* addEntry(string* dynamicArray, int& size, string newEntry) { // you implement this. Please read Programming Project 6 on page 536 // you may watch video notes to get the idea } string* deleteEntry(string* dynamicArray, int& size, string entryToDelete) { // you implement this. Please read Programming Project 6 on page 536 // you may watch video notes to get the idea } void print(const string* dynamicArray, int size) { // you implement this. // you may watch video notes to get the idea }


Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Write a main program to test your function on various strings of both even and odd length
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
