TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: STEVE WESTCOT
from: DANIEL JONES
date: 1997-03-17 05:30:00
subject: file size

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.