Question: Need help with this C++ program. Learning Objectives - Use of arrays to store and manipulate a list of data items. - Reading text files
Need help with this C++ program.


Learning Objectives - Use of arrays to store and manipulate a list of data items. - Reading text files into a program. Writing text files from a program General Description Write a program that reads a list of names from a text file. Sort the list and write the sorted list to a text file. Print the list on the screen before and after it is sorted Specifications: assume the maximum number of names in a list is 20 Write a function that is given a Partial Array [array, number of elements, max number of elements] to alter. It should open a data file called data.txt and read the list of names from the file into the array. It should also set the number of items in the array. The file format is: 1. First Line: contains the number of names in the file Each Line after that: contains one name, which may have spaces in it. The number of lines is the number found on the first line Example Demetrius Johnson Stipe Miocic Daniel Cormier Christiane Justino Michelle Bisping Connor McGregor Note: you may assume the number of names in the file is correct, and 20 or less. 2. Write a function that is given a Partial Array of names. It should print the names on the screen, one name per line, with a blank line after the last name 3. Write a function that alters a Partial Array of strings by sorting the list of names alphabetically lowest to highest. 4. Write a function that is given a Partial Array of names, and writes the array to a text file called output.txt The format of the file should be the same as the format of the input file 5. Write a main program that declares a Partial Array, then invokes the read, print, sort, print and then write functions, in that order. Just before the first print invocation, print "Before sort" on a line. Just before the second print invocation, print "After sort" on a line. Pause at the end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
