Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago