Below code is the normal way to get the input from a text and store it in an array in a structure.
Wanted to ask how can i use pointer to store all these data into the array of structure ? Like p1->Years (this is without array, but how can i apply this to way of writing in below code)
Any better suggestion to use pointer to take in the input?
int years = 4;
struct maju_company {
    int Year;
    float quarter1, quarter2, quarter3, quarter4, total_sales, average_sales;
};
int main() {
    string line;
    maju_company p1[years];
    fstream yeecinnfile("MajuSales.txt");
    if(yeecinnfile.is_open()) {
        //ignoring the first four line of code and store the rest of the code
        string line1,line2,line3,line4;
        getline(yeecinnfile,line1);
        getline(yeecinnfile,line2);
        getline(yeecinnfile,line3);
        getline(yeecinnfile,line4);
        while(!yeecinnfile.eof()) {
            for(int i =0; i<years; i++) {
                yeecinnfile>>p1[i].Year>>p1[i].quarter1>>p1[i].quarter2>>p1[i].quarter3>>p1[i].quarter4;
            }
        }
        for(int i =0; i<years; i++) {
            cout<<p1[i].Year<<setw(10)<<p1[i].quarter1<<setw(10)<<p1[i].quarter2<<setw(10)<<p1[i].quarter3<<setw(10)<<p1[i].quarter4<<endl;
        }
        cout<<endl;
    }
}
 
     
     
     
    