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(); }
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(); }