I have the following code snippet which is the most important as you can see I have two arrays defined of two different classes, my main agenda is printing them both out in a single list in ascending order based on the .GetDay value in each array, however when read from file both arrays are already in ascending order so I need to combine the two when printing I have already tried putting them into an array oof structs which worked perfectly fine till I begin a new loop for printing when printing a last member of the struct it caused the program to crash for some odd reason due to read or write error on the memory so I am assuming i have memory leak somewhere when I did that
int main()
{
Service stran[MAX];
Merchandise mtran[MAX];
ifstream fin;
string month, tcustNumber, sDescription, mItemNumber;
float tAmount;
char type;
int i, j, tDay, mQuantity, sEmpNumber, year;
fin.open("transaction.data");
fin>>month>>year;
while(!fin.eof())
{
fin>>type;
if(type == 'M')
{
fin>>tDay>>tAmount>>tcustNumber>>mItemNumber>>mQuantity;
mtran[i].Initialize(tDay, tAmount, tcustNumber, mItemNumber, mQuantity);
i++;
}
else
{
fin>>tDay>>tAmount>>tcustNumber>>sEmpNumber;
getline(fin,sDescription);
stran[j].Initialize(tDay, tAmount, tcustNumber, sEmpNumber, sDescription);
j++;
}
}
fin.close();
So in short was is the best way to print these two arrays out in a single list in ascending order ?