0

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
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0

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

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.