Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

int main() { int numberOfMusicians = 0; int numberOfWriters = 0; string str1, str2, str3; ifstream fin; // TODO: Open the file music.txt. Print an

int main() {


int numberOfMusicians = 0;

int numberOfWriters = 0;

string str1, str2, str3;

ifstream fin;


// TODO: Open the file music.txt. Print an error message and exit

// the program if the file cannot be opened. 5 pts.



// TODO: Read the number at the beginning of the text file. That number

// indicates the number of musicians in the list (which is also the length

// of the musicians' array). 5 pts.

//

// Dynamically allocate an array of musician objects. The array should be

// the exact length needed to read the file. 10 pts.

//

// Use a for-loop to load the array with the content from the text file. 15 pts.

//

// Close the text file when you are done with it. 5 pts.



// TODO: Open the file writer.txt. Print an error message and exit

// the program if the file cannot be opened. 5 pts.



// TODO: Read the number at the beginning of the text file. That number

// indicates the number of writers in the list (which is also the length

// of the writers' array). 5 pts.

//

// Dynamically allocate an array of writer objects. The array should be

// the exact length needed to read the file. 10 pts.

//

// Use a for-loop to load the array with the content from the text file. 15 pts.

//

// Close the text file when you are done with it. 5 pts.



// TODO: Loop through the musicians' array and print all of its data.

// Then loop through the writers' array and print all of its data. 15 pts.

// Remember to release all dynamically allocated memory before exiting. 5 pts.


return 0;

}

image text in transcribed
image text in transcribed
1 KB 16% Jo 1 KB 18% music - Notepad File Edit Format View Help Miles Davis Trumpet John Coltrane Saxophone Keith Jarrett Piano Keith Richards Guitar Ella Fitzgerald Voice Paul Motian Percussion I KB 16% 1 KB 18% writer - Notepad File Edit Format View Help 7 Tobias Wolff Memoir August Wilson Playwright Te-Ping Chen Journalist Stanislaw Lem SciFi Gertrude Stein Novelist Hunter Thompson Gonzo Khaled Hosseini Novelist

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_2

Step: 3

blur-text-image_3

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions