Question: I need your help with my C++ program to implement the dynamic array allocation (involving pointers, new and delete operators) when reading in and storing

I need your help with my C++ program to implement the dynamic array allocation(involving pointers, new and delete operators) when reading in and storing the content from the readFile.txt file. No hard coding allowed.

Below are the txt file and my codes.

I need your help with my C++ program to implement the dynamic

// The range of 'horizontal' indices, inclusive // E.g. if the range is 0-4, then the indices are 0, 1, 2, 3, 4 GridX_IdxRange=0-8

// The range of 'vertical' indices, inclusive // E.g. if the range is 0-3, then the indices are 0, 1, 2, 3 GridY_IdxRange=0-8

--------------------------------------------------------------------------------------------------------------------------

Codes:

#include #include #include #include

using namespace std;

//function declarations void readFile(); void quit(); void mainMenu();

//global variables

string GridXRange; string GridYRange; ifstream inData;

vector tokenStringVector;

//String tokenization function vector tokenizeString (string input, string delimiter) { size_t pos = 0; string token; vector result;

while((pos = input.find(delimiter)) != string::npos) { token = input.substr(0, pos); result.push_back (token); input.erase(0, pos + delimiter.length()); } result.push_back (input); return (result); }

//main int main() { mainMenu(); return 0; }

//read in a file void readFile() { string readFile;

cout>readFile; cout

//open input file inData.open(readFile);

while (!inData) //while filename does not exist { cout > readFile; inData.open(readFile); }

string line; vector result;

while (getline(inData, line)) { if(line[0] == '/' && line[1] == '/') continue; //Ignore comment lines if(line.size()

//implement the dynamic array here and display the content

}

void quit() { cout

void mainMenu() { int num_choice; cout>num_choice; cout

switch(num_choice) { case 1: readFile(); break;

case 2: quit(); break;

default: cout

------------------------------------------------------------------------------------------------

Desired output: (when user enter choice 1 and types in readFile.txt)

array allocation(involving pointers, new and delete operators) when reading in and storing

readFile - Notepad File Edit Format View Help // The range of 'horizontal' indices, inclusive // E.g. if the range is 0-4, then the indices are 0, 1, 2, 3, GridX_IdxRange=0-8 4 // The range of 'vertical' indices, inclusive // E.g. if the range is 0-3, then the indices are 0, 1, 2, 3 GridY_IdxRange=0-8 Reading in GridX_IdxRange: 0-8...done! Reading in GridY_IdxRange: 0-8... done

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!