I'm writing a program for my class, in the program I make an array of objects that are returned to the main function from another function. The only problem is that once it's returned, I lose like 20% of my data, and the missing data seems to be at random, does anyone know why this happens?

Code from the main function:
Code:
    lottery *history = load_history();

Code from "load_history()" function:
Code:
lottery *load_history(){
     int count=0, count2=0;
     string date;
     int i[6];
     
     ifstream tocount("lottarydata.txt", ios::in);
     while(tocount>>date>>i[0]>>i[1]>>i[2]>>i[3]>>i[4]>>i[5]){
             count++;
             }
     tocount.close();
     
     lottery history[count];
     
     ifstream historydata("lottarydata.txt", ios::in);
     while(historydata>>date>>i[0]>>i[1]>>i[2]>>i[3]>>i[4]>>i[5]){
     history[count2].init(i[0], i[1], i[2], i[3], i[4], i[5], date, count);
     count2++;
     }
     historydata.close();
     
     lottery *ptr=history;
     return ptr;
     }

     void report(lottery *param){
     ofstream report_file("lottoreport.txt", ios::out);
     report_file<<"Total Number of records processed: "<<param[0].total; 
     report_file.close();   
     }
If anyone could tell me why this is happening, I would greatly appreciate it, it's been frustrating me for some time now. If I output all the vairables inside the load_history() function, they all turn out fine, but if I do it from main(), then alot of the variables look like they haven't been assigned a value.