SW> CR> ifstream file("Somefile");
SW> CR> file.seekg(0L, ios::end);
SW> CR> cout << file.tellg();
SW> CR> file.seekg(0L, ios::beg);
SW> Found out the above about a hour later. I read some help on ftell a
SW> tellg to see if there was anything...whala, there was.
SW> Now my problem is deleting a record without changing everything arou
SW> records point to others with an integer as record number. I have a
SW> of code for it, and I am sure I have too much code.
The easiest and most common way to handle this problem is to add a
"deleted" flag to your record structure. Rather than actually deleting
a record from the database, you simply set it's flag to "deleted".
When adding a record to the database, you can write it over a deleted
record rather than appending it to the end of the file. This keeps the
record from containing too much dead space.
If necessary, you can add another routine to go through and pack the
database. You can do this by moving up records within the file. A
usually faster and more efficient way is by reading in the (non-deleted)
records and rewriting them to another file. Once the second file is
written, delete the original file and rename the second.
Regards,
Daniel ddjones@pinn.net
---
þ RM 1.31 1604 þ "Bother," said Pooh, as he ate the baby's candy.
---------------
* Origin: Selective Source Virginia Beach, VA (757)471-6776 (1:275/102)
|