Question
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;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started