Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this part of the lab you will write a program that does the following operations: Reads words from a file (words_in.txt), with one word

image text in transcribed

In this part of the lab you will write a program that does the following operations: Reads words from a file (words_in.txt), with one word per line. Creates an array, using dynamic memory allocation, large enough to contain those words (one word per array element). Output the words (array elements) to another file (words_out.txt). Before storing the words from a file in an array, you will need to first find out how many lines there are in the file: one way to do it is to check with a counter when you reach the end of the file, by using the function e of(). E of() returns true (1) if the end of file is reached, otherwise a false (0) is returned. You can review the use of e of() at: http://mathbits.com/MathBits/CompSci/Files/End.htm Once you have found out how many lines there are in the file, you can create a dynamically allocated array of strings, which is as large as the number of words contained in the file (as per the counter you have implemented). You can review the syntax to declare arrays with dynamic memory allocation (pointerew) in the lecture slides or at cplusplus.com. Finally, you will write each word (array element) into the output file, one word per line. In this part of the lab you will write a program that does the following operations: Reads words from a file (words_in.txt), with one word per line. Creates an array, using dynamic memory allocation, large enough to contain those words (one word per array element). Output the words (array elements) to another file (words_out.txt). Before storing the words from a file in an array, you will need to first find out how many lines there are in the file: one way to do it is to check with a counter when you reach the end of the file, by using the function e of(). E of() returns true (1) if the end of file is reached, otherwise a false (0) is returned. You can review the use of e of() at: http://mathbits.com/MathBits/CompSci/Files/End.htm Once you have found out how many lines there are in the file, you can create a dynamically allocated array of strings, which is as large as the number of words contained in the file (as per the counter you have implemented). You can review the syntax to declare arrays with dynamic memory allocation (pointerew) in the lecture slides or at cplusplus.com. Finally, you will write each word (array element) into the output file, one word per line

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

LO3 Discuss the steps of a typical selection process.

Answered: 1 week ago