How can I ignore the first line of the text file and start at the second line when I called it in the code? I was wondering how. Also, how can I sort the file according to first name, last name and grade? I just have the first name sorted but not the last name and grade accordingly. If you have any idea, I hope you can share it with me. Thanks for the help! Here's my code:
#include <iostream>
#include <fstream>
using namespace std;
  
struct studentRecord{
    string lastname;
    string firstname;
    string grade;
};
 
int main(){
    ifstream  ifs("student-file.txt");
    string lastname, firstname, grade, key;
    
    studentRecord records[20];
    if(ifs.fail()) {
        cout << "Error opening student records file" <<endl;
        exit(1);
     }
    int i = 0;
    while(! ifs.eof()){
        ifs >> lastname >> firstname >> grade;
        records[i].lastname = lastname;
        records[i].firstname = firstname;
        records[i].grade = grade;
        i++;
    }  
 
    for (int a = 1, b = 0; a < 20; a++) {
        key = records[a].firstname ;
        b = a-1;
                
        while (b >= 0 && records[b].firstname > key) {
            records[b+1].firstname = records[b].firstname;
            b--;
        }
        records[b+1].firstname = key;
    }
    for (int k = 0; k < 20; k++) {
        cout << "\n\t" << records[k].firstname << "\t"<< records[k].lastname << "\t" << records[k].grade;
    }
 
}
 
     
    