Question: I need help modifying this function. I need it to prompt the user for the file name and store it's contents in into the dynamic

I need help modifying this function. I need it to prompt the user for the file name and store it's contents in into the dynamic array. Instead of asking for the value from the user as it does. I have been working on this for hours with no luck.

struct text { char* word {}; };

void FillArray(text*& ray, int& num_words) { char buffer[256] = "";

cout > num_words;

ray = new text[num_words];

for (int i = 0; i in_avail()); cin.getline(buffer, 255); cin.clear(); cin.ignore(cin.rdbuf()->in_avail()); ray[i].word = new char[strlen(buffer) + 1]; strcpy(ray[i].word, buffer);

cout in_avail()); cin.getline(buffer, 255); cin.clear(); cin.ignore(cin.rdbuf()->in_avail()); ray[i].department = new char[strlen(buffer) + 1]; strcpy(ray[i].department, buffer); } }

Example input:

This

is a

test input

Example output

I need help modifying this function. I need it to prompt the

00000000 00000010 00000020 00000030 03 00 00 00 05 00 00 00 00 05 00 00 00 69 73 20 00 00 74 65 73 74 20 69 00 | 54 68 69 73 00 05 00 00 61 00 05 00 00 00 OB 00 6E 70 75 74 00 OB 00 00 .This.... ....is a.... ..test input.... 00000000 00000010 00000020 00000030 03 00 00 00 05 00 00 00 00 05 00 00 00 69 73 20 00 00 74 65 73 74 20 69 00 | 54 68 69 73 00 05 00 00 61 00 05 00 00 00 OB 00 6E 70 75 74 00 OB 00 00 .This.... ....is a.... ..test input

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!