Question: Exercise P7.15. Exercise P7.14 demonstrated how to use the string and vector classes to implement resizable arrays. In this exercise, you should implement that capability

Exercise P7.15. Exercise P7.14 demonstrated how to use the string and vector classes to implement resizable arrays. In this exercise, you should implement that capability manually. Allocate a buffer of 1,000 characters from the heap (new char[1000]). Whenever the buffer fills up, allocate a buffer of twice the size, copy the buffer contents, and delete the old buffer. Do the same for the array of char* pointersstart with a new char*[100] and keep doubling the size.

**(I dont think i answered the question right with my code, can anybody help? Its C++)**

#include #include #include

using namespace std;

/**define macros to define line size and arrays length**/ #define SIZE 1000 #define Line_Size 100

/**Function to print the elements**/ void Print(char**& input_line,int line_count) { int i; cout << "Characters entered, line by line now in a new array with double the size: "; for( i=0;i<=line_count;i++) { cout<

/**Function to resize the array and delete old array**/ void IncreaseArray(char *&CurrArray,int &Currentsize) { /*Multiply the value of Currentsize by two and assigned it into Currentsize.*/ Currentsize=Currentsize*2; char*ptr=new char[Currentsize]; /*Iterate the for loop until the old size of the array.*/ for(int i=0;i0;i--) { input_line[i]=input_line[i]-input_line[0]+input_str; } input_line[0]=input_str; } /**Function to resize the line size**/ void IncreaseLineArraySize(char**&input_line,int&LineSize) { LineSize=LineSize*2; char**ptr=new char*[LineSize]; int r=LineSize/2-1; /*Iterate for loop until the value of i is less than equals to r.*/ for(int i=0;i

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!