Question: program in c. Please write comments so I could understand the code. Thank you. Write a function that reads an input file and creates a
program in c. Please write comments so I could understand the code. Thank you.
Write a function that reads an input file and creates a sorted output file. The function prototype is void file_sort(char *infile, char *outfile). The function takes the file names as parameters. The input file contains student information and has the following format. The first line contains the number of students in the file. Each subsequent line contains information about one student. Each line contains three fields namely student id, grade, and gpa in that order separated by blanks. The student id is a positive integer. The grade is a character. The gpa is a double type value. The function sorts the student information in the ascending order of student id. The ordered student information is written to the output file. The output file has the same format as the input file. The function dynamically allocates three arrays and stores the student information into the arrays. The three arrays are simultaneously sorted. The sorted array information is written to the output file. The dynamic arrays are freed when the function completes its work. Structures should not be used.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
