Hi guys, i am doing one accounting project. I use 3 binary files to store account holders information, login information and transaction. For mini-statement i need to read my Transaction binary file in backward. i dont know how to do ...

My structure is

struct Transaction_Info
{
   int AccountNumber;
   bool AccountType; // true->savings account,  false->current account
   double Balance;
   Date_Time dt;
};
//Binary file writing
for writing Binary files i use
   Transaction_Info Tdata;
   //Read Tdata input from user
   fstream file("file path", ios::binary | ios::out | ios::app);
   file.write(reinterpret_cast<char*>(&Tdata), sizeof(Transaction_Info));
But i dont know how to read binary file from backward for mini-statement, if any one know the technique pls explain with sample code

Thanks in advance

1)seek to end of file

Start of loop
   Read a record
   // back up two records, 
   file.seekg(-(2* sizeof(Transation_Info), ios::cur);
   beginninng of file?
     yes, then exit loop
end of loop
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.