Page 445 - C++
P. 445

ofstream fout("sch_temp.dat",ios::out|ios::binary);
                       cout<<"\nEnter the date & time of that schedule which you want to
                delete "
                           <<"\nDay = ";
                       cin>>d.dd;
                       cout<<"\nMonth = ";
                       cin>>d.mm;
                       cout<<"\nYear = ";
                       cin>>d.yy;
                       while(fin.read((char*)&S,sizeof(S)))
                       {
                              if(S.check_dt(d))
                              {
                                      S.SDisplaydata();
                                      cout<<"\nIs this the schedule you want to delete? ";
                                      cin>>r;
                                      if(r=='y'||r=='Y')
                                      {
                                             cout<<"\ndeleted :) ";
                                      }
                                      else
                                      {
                                             cout<<"\nNo problem :) ";
                                             fout.write((char*)&S,sizeof(S));
                                      }
                              }
                              else
                                      fout.write((char*)&S,sizeof(S));
                       }
                       fin.close();
                       fout.close();
                       remove("schedule.dat");
                       rename("sch_temp.dat","schedule.dat");
                       getch();
                }
                /*************************************************************/
                void sch_modify()
                {
                       ifstream fin("schedule.dat",ios::in|ios::binary);
                       ofstream fout("sch_temp.dat",ios::out|ios::binary);
                       Schedule S;
                       Date d;
                       int flag;
                       cout<<"\nEnter the date & time of that schedule which you want to
                modify "
                           <<"\nDay = ";
                       cin>>d.dd;
                       cout<<"\nMonth = ";
                       cin>>d.mm;
                       cout<<"\nYear = ";
                       cin>>d.yy;
                       while(fin.read((char*)&S,sizeof(S)))
                       {
                              if(S.check_dt(d))
   440   441   442   443   444   445   446   447   448   449   450