Filing problem!

E

Ebi

It's a main function of club program in Borland c++ 5;
There is a film class in my club program...
But I have a problem with it: whenever I add a film by addfilm function
to film.dat file, data(objects) that I add before remove, and there is
an object available at per time. And I can't add more than one film,
because the previous film object remove.
Please help me.

//********************************************** 1.addfilm *­*
void addfilm()
{
film film1;
film1.setstate(1);
ofstream fp("film.dat", ios::binary);
if(!fp) {
cout<<"Cannot open file."<<endl;
system("PAUSE");
exit(0); }
cout<<endl;
film1.puttitle();
film1.setid();
cout<<"Enter Artists: ";
cin>>film1.artists;
cout<<"Enter Director: ";
cin>>film1.director;
cout<<"Enter Company: ";
cin>>film1.company;
cout<<"Enter Producer: ";
cin>>film1.producer;
cout<<endl;

fp.seekp(sizeof(class film)*film1.getid(), ios::beg);
fp.write((char*)&film1, sizeof(class film));
fp.close(); }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top