Do you have to use a binary file? They are more static than dynamic. If possible use a sequenual file or database, which you can have dynamic fields.


Erica Web <[EMAIL PROTECTED]> wrote:

Hello

 

I need help for a class project.

I have a class for a student. This information is written to a binary file using the ofstream object.

I need to go to a particular place and overwrite the information without destroying the other stuff in the file.

This is what I have for my function:

 

void Student::diskOutDel(int pn)

{

            Student t;

            fstream file("Register.dat", ios::ate | ios::out | ios::binary);

            file.write((char*)&t, 0);

            file.seekp(pn * sizeof(*this), ios::beg);

            //cout << file.tellp() << endl;

            file.write((char*)this, sizeof(*this));

            file.close();

 

}

 

When I do this, it will write it at the right position, but everything else is gone.

I am looking all over planet source code for an example but it is not coming to me.

As you can see I am using seekp() to put the pointer in the right position

Also, I need to delete a person from this file in another function.

Do I just insert an empty student into the place of the old student, or is there something else I can do for that?

But it is just not working. Any help is greatly appreciated.

Thanks in advance.



To unsubscribe, send an email to:
[EMAIL PROTECTED]





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 9/17/2004


Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

To unsubscribe, send an email to:
[EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=315388.5500238.6578046.3001176/D=groups/S=:HM/A=2372354/rand=799493528


Yahoo! Groups Links

Reply via email to