Ok so my write function works!
Code:
void fincal2Frame::OnClose(wxCloseEvent &event)
{
theBar->RemoveIcon();
fout.open("list.txt");
for (int i = 0; i < m_TheList->getSize();i++){
//BillData billdat = m_TheList->getDat(i);
/*
fout.write((char*)&billdat.Cost, sizeof wxString);
fout.write((char*)&billdat.DueDate, sizeof wxDateTime);
fout.write((char*)&billdat.Name, sizeof wxString);*/
fout << m_TheList->getCost(i) << "\n";
fout << m_TheList->getDate(i)<< "\n";
fout << m_TheList->getName(i) << "\n";
}
fout.close();
Destroy();
}
and outputs to a file like
but i'm having trouble getting it back into the program when it starts. This is what i have so far, but it doesn't work right.
Code:
fin.open("list.txt"); //Load the list of bills.
if (fin && fin.peek()){ // if the file was found.
while (!fin.eof() ){
wxString TempName, TempCost;
int TempDate;
char buffer[256],buffer2[256];
// BillData temp("","",wxDateTime::Now());
fin >> buffer;
TempCost = _T(buffer);
fin >> TempDate;
fin >> buffer2;
TempName = _T(buffer);
m_TheList->InsertBill(TempName,TempCost,TempDate);
}
}
fin.close();