Question: Write a program to allow the user to enter an input file name and an output file name. Only if both files are successfully opened,

Write a program to allow the user to enter an input file name and an output file name. Only if both files are successfully opened, read the input file data into two parallel arrays. The input file will contain data in the following order: The first line will contain a name for a person with the following line containing their age. The name will be a full name with their last name first, possible middle initial, and their first name. The maximum size of the full name will be 40 characters. The age will be an integer. Data will follow in the same order: name, age, name, age, etc. There will be a maximum of up to ten people with their age. Store the full names in an array of strings, i.e. a two dimensioned array of characters. The ages will be stored in an array of integers. Manage the arrays as parallel arrays. Data entry will be from the input file and will read the full name followed by the age. Data entry will terminate when the arrays are full or when the end of file is reached. Use a function to enter the data by passing the arrays to the function, do not use global arrays. Once the data is completely entered, use another function to print out the arrays to the screen and output file, again pass the data do not use global data. Then use a function to sort the data on the full names in ascending order, keep the ages related to the person. Reuse the print function and print the sorted data out to the screen. Write another function which sorts the data on age as the primary sort and full name as the secondary sort. Finally reuse the print function to print the data to the screen. All data will be passed to the functions, no global data.

I know I need the following:

int readdata(FILE*, char[][], int[]);

void printdata(FILE*, char[][], int[], int);

void sortname(char[][], int[], int);

void sortage(char[][], int[], int);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!