Entering and storing records

I am writing a program that will allow the user to enter new student record(student ID and the corresponding mark). The program will then store this record and can be retrieved for later use (such as determining the average mark or displaying records).

My question is, what will be the best approach/method to code this section of the program?

Additional info:
The records are stored in a struct:
1
2
3
4
5
6
struct StudentRecord
     {
       string studentID;
       float studentMark;
       char studentGrade;
     } student;


And the default records are:
1
2
3
4
5
StudentRecord student[] = 
                  {
                  {"P1001",78.50,'D'},
                  {"P1002",66,'C'}
                  };


When the program displays the records, it will be using the linear search method.
Store your student records in a std::vector.
Write a function to ask the user for information and return a StudentRecord, which can be inserted into the vector.

[edit] A good way to initialize a vector with static data:
1
2
3
4
5
6
7
8
9
const StudentRecord initial_student_records[] = 
  {
  {"P1001",78.50,'D'},
  {"P1002",66,'C'}
  };
vector <StudentRecord> student_records(
  initial_student_records,
  initial_student_records + (sizeof(initial_student_records) / sizeof(StudentRecord))
  );


Good luck!
Last edited on
Topic archived. No new replies allowed.