to use a vector of structs to sort the data. You are
collecting a file of information about students who are applying to your program.
The file contains the first name, last name, GPA, and age of each student. Your
tasks are to 1) read this data in from the user-specified file to a vector of structs
2)sort the data in ascending order by the user-specified criteria, and 3)print the
sorted data to the screen for review.
It will be most helpful to break each activity into a separate function. In my
solution, I wrote the following functions:
A File Reading Function for the vector of structs
Sort functions (based on what option you insert)
A Print Function
Details and Specifications
Collections of data which, together, describe a more complex object are
common in the real world. For example, such information as first name, last name,
social security number, address, and age may be collected together to form a more
complex object called “Person”. In the case of Lab 4, we are collecting first name,
last name, GPA, and age data to represent a student. You need to define a correct
struct to represent student.
The user-specified input file will contain data for a certain number of
students, one on each line.
Each line of the input file has the following format:
In your main function, you will need to create a vector of student structs.
To read in the students data into vector of students, you should write a
function. The file reading functions should open the user-specified file and read the
student data into the array using sentinel loop logic.
You may use push_back(), size(), and some other functions from .
To sort the student data for each storage system, you should write a function.
The sorting function should sort students in ascending order (small to large)
according to the criteria the user has specified. These sorting functions should
NOT simply print the sorted order, but should actually modify the student vector in
memory so that they are stored in sorted order.
Printing the data should be straightforward, simply mimic the output from
my example output captures below: (Note: Output menu and sorted table should be
column-aligned using setw( ), you can assume that first and last names will be no
longer than 25 characters)
Your program should have the exact output as following:
Use two files
(1) student.h : declare your student struct
(2) [url removed, login to view]: write your programs in this file