473,890 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Needed in file handling

> > Hi, this is Abhas,
I had made a video library program in C++, but was facing a problem.
After entering 12 movies, i cannot enter any more movies.
Something gibberish comes instead.
Can somebody please tell whats wrong??
This is the code : :

#include<fstrea m.h>
#include<conio. h>
#include<stdio. h>
#include<proces s.h>
#include<string .h>
#include<dos.h>

/*
USE OF HEADER FILES :
FSTREAM.H = FOR DATABASE MANAGEMENT(STRE AMS ETC...), IOSTREAM.H
CONIO.H = FOR TEXTCOLOR, CLRSCR(), GETCH() ETC...
STDIO.H = RENAME, REMOVE, GETS(), PUTS() ETC...
PROCESS.H = FOR EXIT()
STRING.H = FOR STRING RELATED FUNCTIONS
DOS.H = FOR _DOS_GETDATE FUNCTION
*/

void pass(); //TO INPUT A PASSWORD TO ACCESS THE PROGRAM

struct date1
{
int dd, mm, yyyy;
};
struct dosdate_t d; //TO GET CURRENT DATE

//*************** *************** *************** *************
//CLASS TO MAINTAIN MOVIE FILE
//*************** *************** *************** *************

class movie
{
public:
int mcode;
char mlang[20];
int mrelease;
char vtype[10];
char mname[40];
char issued;
movie (); //CONSTRUCTOR
int rec_no();
void input();
void display();
void modify();
friend void header(); //FRIEND FUNCTION
friend char upper(char*); //FRIEND FUNCTION
void madd();
void mshow();
void msearch();
void modmovie();
void modyear();
void modlang();
void modstat(char,ch ar []);
int movieissued(cha r[]);
void mdelete();
} m1;
movie :: movie()
{
issued='f'; //ASSIGNS FALSE FIELD FOR UNISSUED MOVIES
}
int movie :: rec_no()
{
fstream mfile;
int recno;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0,i os::end);
int n=mfile.tellg() ;
mfile.close();
if (n<=0||mfile.eo f())
{
recno=1;
return recno;
}
else
{
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
recno=m1.mcode;
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
return (recno+1);
}
}
int movie :: movieissued(cha r mname[])
{
fstream mfile;
int found;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,mname)==0) )
{
if(m1.issued==' f')
{
found=0;
}
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
return found;
}
void movie :: input()
{
cout<<"\n\t\t MOVIE CODE : ";
cout<<mcode<<en dl ;
cout<<"\t\t ENTER THE MOVIE NAME : ";
gets(mname);
cout<<"\t\t ENTER THE MOVIE LANGUAGE : ";
cin>>mlang;
cout<<"\t\t ENTER THE RELEASE YEAR : ";
cin>>mrelease;
cout<<"\t\t ENTER THE VIDEO TYPE (CD/DVD/CASSETTE) : ";
cin>>vtype;
cout<<"\t\t ISSUED : ";
cout<< m1.issued;
}

//*************** *************** *************** *************** *****
//CODE FOR ADDING NEW MOVIES TO THE FILE
//*************** *************** *************** *************** *****

void movie :: madd()
{
fstream mfile;
char ans='y';
mcode=rec_no();
mfile.open("mov ie.dat",ios::ou t|ios::app) ;
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\n\n \t\t\t MOVIE DETAILS "<<endl;
cout<<"\t\t\t -------------"<< endl;
m1.input();
mfile.write((ch ar*)&m1,sizeof( m1));
mcode=mcode+1;
cout<<"\n\t\t CONTINUE (Y/N) : ";
cin>>ans ;
}
mfile.close();
}
void movie :: mshow()
{
fstream mfile;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
m1.display();
cout<<endl ;
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
}
void movie :: display()
{
cout<<"\n\t\t\t MOVIE CODE : ";
cout<<mcode<<en dl ;
cout<<"\t\t\t MOVIE NAME : ";
puts(mname);
cout<<"\t\t\t MOVIE LANGUAGE : ";
cout<<mlang;
cout<<"\n\t\t\t RELEASE YEAR : ";
cout<<mrelease;
cout<<"\n\t\t\t VIDEO TYPE : ";
cout<<vtype;
cout<<"\n\t\t\t ISSUED : ";
cout<<m1.issued ;
}

//*************** *************** *************** **********
//CODE TO SEARCH FOR A MOVIE
//*************** *************** *************** **********

void movie :: msearch()
{
fstream mfile;
char m[20];
int counter=0;
cout<<"\n\n\n\t \tENTER THE MOVIE TO BE SEARCHED:";
gets(m);
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,m)==0))
{
counter++;
m1.display();
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
if (counter==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
textcolor(WHITE );
}
}

//*************** *************** *************** ************
// CODE FOR MODIFYING INFO OF A MOVIE IN A FILE
//*************** *************** *************** ************

void movie :: modify()
{
int ch;
do
{
aa: clrscr();
header();
cout<<"\n\n\n\n \t\t\t MODIFY MENU ";
cout <<"\n\t\t\t ---------- ";
cout<<"\n\t\t\t 1: MODIFY MOVIE NAME ";
cout<<"\n\t\t\t 2: MODIFY RELEASE YEAR ";
cout<<"\n\t\t\t 3: MODIFY LANGUAGE ";
cout<<"\n\t\t\t 4: RETURN TO MAIN MENU";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>ch;
switch(ch)
{
case 1 : clrscr();
header();
m1.modmovie();
break;
case 2 : clrscr();
header();
m1.modyear();
break;
case 3 : clrscr();
header();
m1.modlang();
break;
case 4 : break;
default : cout<<"\n\n\n\n \n\n\n\t\t\t INVALID CHOICE !!!!!!!!! ";
getch();
goto aa;
}
} while(ch>1 && ch<4);
}
void movie :: modmovie()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout<<"\n\n\t\t ENTER THE MOVIE NAME TO BE MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t ENTER THE NAME: ";
gets(m1.mname);
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}
void movie :: modyear()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout<<"\n\n\t ENTER THE MOVIE NAME IN WHICH YEAR IS TO BE MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t \t ENTER THE YEAR:";
cin>>m1.mreleas e;
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}
void movie :: modlang()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout <<"\n\n\t ENTER THE MOVIE NAME IN WHICH LANGUAGE TO BE
MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t ENTER THE LANGUAGE: ";
gets(m1.mlang);
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof (m1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch () ;
textcolor(WHITE );
}
mfile.close();
}

//*************** *************** *************** ***************
//MODIFIES THE STATUS ON RETURNING A MOVIE
//*************** *************** *************** ***************

void movie :: modstat(char ch,char name[])
{
int found =0;
fstream mfile;
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name))==0)
{
m1.issued=ch;
found++;
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}

//*************** *************** *************** *************** **
//CODE FOR DELETING A MOVIE
//*************** *************** *************** *************** **

void movie :: mdelete()
{
fstream mfile,m1file;
char mname[20];
int count=0;
cout<<" \n\n\t\t\tENTER THE MOVIE TO BE DELETED: ";
gets(mname);
mfile.open("mov ie.dat",ios::in );
m1file.open("mo vie1.dat",ios:: app|ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if(strcmp(m1.mn ame, mname)!=0)
{
m1file.write((c har*)&m1,sizeof (m1));
count++;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
m1file.close();
remove("movie.d at");
rename("movie1. dat","movie.dat ");
if (count!=0)
{
gotoxy(27,25);
textcolor(RED+B LINK);
cprintf(" MOVIE DELETED !!!!");
textcolor(WHITE );
}
}

//*************** *************** *************** ***************
//CLASS FOR MAINTAINING VIDEO PRICES
//*************** *************** *************** ***************

class video
{
char vtype[15];
float vprice;
float vexch;
protected:
int vcode;
public:
void vinput();
void vdisplay();
void vadd();
int type_exist(char[]);
int type_check(char[]);
int rec_no();
int calexcharges(ch ar [],int);
}v1;
int video :: calexcharges(ch ar name[],int i)
{
fstream mfile,vfile;
char type[10];
int ch;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
strcpy(type,m1. vtype);
}
mfile.read((cha r*)&m1,sizeof(m 1));
}

vfile.open("vid eo.dat",ios::in );
vfile.seekg(0, ios::beg);
vfile.read((cha r*)&v1,sizeof(v 1));
while(!vfile.eo f())
{
if((strcmp(type ,v1.vtype)==0))
{
ch=v1.vexch;
}
vfile.read((cha r*)&v1,sizeof(v 1));
}
mfile.close();
vfile.close();
int exch=ch*i;
return exch;
}
void video :: vinput()
{
int check, found;
cout<<"\n\t\t ENTER THE VIDEO CODE :";
cin<<vcode;
cout<<"\t\t ENTER THE VIDEO TYPE (CD/DVD/CASSETTE) :";
cin>>vtype;
cout<<"\t\t ENTER THE VIDEO PRICE :Rs. ";
cin>>vprice;
cout<<"\t\t ENTER THE EXTRA CHARGES(PER DAY) :Rs. ";
cin>>vexch;
}

//*************** *************** *************** **************
//CODE FOR ADDING VIDEO TYPE TO A FILE
//*************** *************** *************** **************

void video :: vadd()
{
fstream vfile;
char ans='y';
vfile.open("vid eo.dat",ios::in |ios::app);
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\n\t \t\t VIDEO DETAILS";
cout<<"\n\t\t\t -------------";
v1.vinput();
vfile.write((ch ar*)&v1,sizeof( v1));
vcode=vcode+1;
cout<<"\t\t CONTINUE (Y/N) :";
cin>>ans;
}
vfile.close();
}

//*************** *************** *************** *************** **
//CLASS TRANSACTION:
// FOR MAINTAINING CUSTOMER FILE AND RELATED RECORDS
//*************** *************** *************** *************** **

class trans : public movie, public video
{
date1 curr_date,ret_d ate;
int id;
char cname[20];
char cadd[40];
float charges;
int days;
int nddays;
char ch;
public:
int cinput();
void cuadd();
void mcdisplay(char []);
void cdisplay(char []);
int rec_no();
void report();
void cdelete(char[]);
void search_menu();
void mcsearch();
void csearch();
void dheader();
void lmdisplay();
void d1header();
void lmadisplay();
void cshow();
void cheader();
void lmrdisplay();
int check_day(int,i nt);
void retdate();
void show_date(int,i nt,int,int);
void ddays();
int showdays(int,in t);
friend int validate(date1 &da);
}t1;
int trans :: rec_no ()
{
fstream cfile;
int rno;
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
int n=cfile.tellg() ;
cfile.close() ;
if (n<=0||cfile.eo f())
{
rno=1;
return rno;
}
else
{
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1,sizeof(t 1));
while(!cfile.eo f())
{
rno=t1.id;
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
return (rno+1);
}
}
int trans :: cinput()
{
int k;
cout<<"\n\t\t CUSTOMER ID : ";
cout<<id<<endl;
cout<<"\t\t ENTER THE CUSTOMER NAME : ";
gets(cname);
cout<<"\t\t ENTER THE ADDRESS : ";
gets(cadd);
cout<<"\t\t ENTER THE MOVIE NAME : ";
gets(mname);
k=m1.movieissue d(mname);
if (k==0)
{
m1.modstat('t', mname);
cout<<"\t\t ENTER THE MOVIE CHARGES : Rs. ";
cin>>charges;
cout<<"\t\t ENTER NO.OF DAYS,MOVIE ISSUED : ";
cin>>days;
cout<<"\t\t ENTER THE ISSUE DATE(dd/mm/yyyy): ";
ll: cin>>curr_date. dd>>ch;
cin>>curr_date. mm>>ch;
cin>>curr_date. yyyy;
if (validate(curr_ date)==0)
{
gotoxy(27,22);
textcolor(WHITE +BLINK);
cprintf("INVALI D DATE!!! ");
getch() ;
textcolor(WHITE );
gotoxy(27,22);
clreol();
gotoxy(56,12);
clreol();
goto ll;
}
cout<<"\t\t RETURN DATE : ";
retdate();
cout<<"\t\t\t\t \tISSUED(T/F) : ";
cin>>issued;
}
else
{
gotoxy(25,20);
textcolor(WHITE +BLINK);
cprintf("MOVIE ALREADY ISSUED OR DOES NOT EXIST");
getch() ;
textcolor(WHITE );
gotoxy(25,20);
clreol();
}
return k;
}

//*************** *************** *************** *************** *********
//CODE FOR ADDING CUSTOMER RECORD TO A FILE OR ISSUE A MOVIE
//*************** *************** *************** *************** *********

void trans :: cuadd()
{
int aa;
fstream cfile;
char ans='y';
id=rec_no();
cfile.open("cus t.dat",ios::out |ios::app) ;
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\t\t \t ISSUE DETAILS";
cout<<"\n\t\t\t -------------" ;
aa=t1.cinput();
if(aa==0)
{
cfile.write((ch ar*)&t1,sizeof( t1));
id=id+1;
}
cout<<"\n\t\t\t CONTINUE (Y/N) : ";
cin>>ans;
}
cfile.close();
}
void trans :: cdisplay(char name[])
{
int tcharges;
cout<<"\n\t\t\t CUSTOMER ADDRESS : ";
puts(cadd);
cout<<"\t\t\t MOVIE NAME : ";
puts(mname);
cout<<"\t\t\t MOVIE CHARGES : Rs. "<<charges;
cout<<"\n\t\t\t ISSUED DAYS : "<<days;
cout<<"\n\t\t\t ISSUED DATE(DD/MM/YY) :
"<<curr_date.dd <<ch<<curr_date .mm<<ch<<curr_d ate.yyyy;
cout<<"\n\t\t\t RETURN DATE :
"<<ret_date.dd< <ch<<ret_date.m m<<ch<<ret_date .yyyy;
cout<<"\n\t\t\t DUE DAYS : ";
ddays() ;
int exch=calexcharg es(name,t1.ndda ys);
cout<<"\n\t\t\t EXTRA CHARGES : Rs. "<<exch;
tcharges=exch+t 1.charges;
cout<<"\n\t\t\t TOTAL CHARGES : Rs. "<<tcharges ;
}
void trans :: mcdisplay(char name[])
{
int tcharges;
cout<<"\n\t\t\t CUSTOMER NAME : ";
puts(cname);
cout<<"\t\t\t CUSTOMER ADDRESS : ";
puts(cadd);
cout<<"\t\t\t MOVIE CHARGES : Rs. "<<charges;
cout<<"\n\t\t\t ISSUED DAYS : "<<days;
cout<<"\n\t\t\t ISSUED DATE(DD/MM/YY) :
"<<curr_date.dd <<ch<<curr_date .mm<<ch<<curr_d ate.yyyy;
cout<<"\n\t\t\t RETURN DATE :
"<<ret_date.dd< <ch<<ret_date.m m<<ch<<ret_date .yyyy;
cout<<"\n\t\t\t DUE DAYS : ";
ddays() ;
int exch=calexcharg es(name,t1.ndda ys);
cout<<"\n\t\t\t EXTRA CHARGES : Rs. "<<exch;
tcharges=exch+t 1.charges;
cout<<"\n\t\t\t TOTAL CHARGES : Rs. "<<tcharges ;
}
int showdays(int,in t);

void trans :: ddays()
{
struct dosdate_t d;
_dos_getdate(&d );
int ch=0;
int ddays=0;
int mm=ret_date.mm;
if(d.day<=ret_d ate.dd)
{
t1.nddays=ddays ;
cout<<"-";
}
else
{
if(d.month==mm)
{
switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=d.day-ret_date.dd;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=d.day-ret_date.dd;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=d.day-ret_date.dd;
mm++ ;
}
else
{
ddays=d.day-ret_date.dd;
mm++;
}
break;
}
ch++;
}
else
{
switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=31-ret_date.dd;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=30-ret_date.dd;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=29-ret_date.dd;
mm++;
}
else
{
ddays=28-ret_date.dd;
mm++;
}
break;
}
ch++;
}

if(d.year==(ret _date.yyyy+1))
{
if (mm==13)
mm=1;
while(mm<d.mont h)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=showda ys(ddays,31);
mm++ ;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=showda ys(ddays,30);
mm++ ;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=showdays( ddays,29);
mm++ ;
}
else
{
ddays=showdays( ddays,28);
mm++;
}
break;
}
ch++;
}
if (mm==d.month)
goto ll;
}
}
{
if (ret_date.yyyy= =d.year)
{
if(d.month==(re t_date.mm+1))
{
ll: switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=d.day ;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=d.day ;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=d.day;
mm++;
}
else
{
ddays+=d.day;
mm++;
}
break;
}
ch++;
}
else
{
while(mm<d.mont h)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=31;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=30;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=29;
mm++;
}
else
{
ddays+=28;
mm++;
}
break;
}
if (mm==d.month)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=d.day ;
mm++ ;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=d.day ;
mm++ ;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=d.day;
mm++;
}
else
{
ddays+=d.day;
mm++;
}
break;
}
ch++;
}
}
}
}
t1.nddays=ddays ;
cout<<t1.nddays ;
}
}
int trans :: showdays(int duedays,int lastd)
{
duedays+=lastd;
return duedays;
}

//*************** *************** *************** *************** *************** *****
//CODE FOR SEARCHING A CUSTOMER RECORD AND DELETE IT,IN CASE OF
RETURNING
//THE MOVIE
//*************** *************** *************** *************** *************** *****

void trans :: search_menu()
{
int choice;
do
{
ac: clrscr();
header();
cout<<"\n\n\n\n \t\t\t SEARCH MENU ";
cout<<"\n\t\t\t ----------- ";
cout<<"\n\t\t\t 1: SEARCH BY CUSTOMER NAME ";
cout<<"\n\t\t\t 2: SEARCH BY MOVIE NAME ";
cout<<"\n\t\t\t 3: RETURN TO MAIN MENU ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch(choice)
{
case 1: clrscr();
header();
t1.csearch();
getch();
break;
case 2: clrscr();
header();
t1.mcsearch();
getch() ;
break;
case 3: break;
default: cout <<"\n\n\n\n\n\n \t\t\t INVALID CHOICE !!!!!!!!! ";
getch () ;
goto ac;
}
}while(choice>= 1&&choice<3);
}
void trans :: mcsearch()
{
char ans = 'y';
char name[20] ;
char pname[20];
fstream cfile;
cout<<"\n\t\tEN TER THE MOVIE NAME TO BE SEARCHED: ";
gets(name);
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
while(!cfile.eo f())
{
if((strcmp(t1.m name,name)==0))
{
t1.mcdisplay(na me);
cout<<"\n\n\n\t \t DO YOU WISH TO DELETE?(Y/N): ";
cin>>ans;
if (ans=='y'||ans= ='Y')
{
cdelete(t1.cnam e);
}
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
void trans :: csearch()
{
char ans = 'y' ;
char name[20];
char pname[20];
fstream cfile;
cout<<"\n\t\tEN TER THE CUSTOMER NAME TO BE SEARCHED: ";
gets(name);
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
while(!cfile.eo f())
{
if((strcmp(t1.c name,name)==0))
{
t1.cdisplay(t1. mname);
cout<<"\n\n\n\t \t DO YOU WISH TO DELETE?(Y/N): ";
cin>>ans;
if (ans=='y'||ans= ='Y')
{
cdelete(name);
}
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
void trans :: cdelete(char name[])
{
fstream cfile,c1file;
char cname[20];
cfile.open("cus t.dat",ios::in) ;
c1file.open("cu st1.dat",ios::a pp|ios::out);
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1, sizeof(t1));
while(!cfile.eo f())
{
if(strcmp(t1.cn ame,name)!=0)
{
c1file.write((c har*)&t1,sizeof (t1));
}
else
{
m1.modstat('f', t1.mname);
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
c1file.close();
remove("cust.da t");
rename("cust1.d at","cust.dat") ;
}

//*************** *************** *************** *************** ******
//CODE FOR CHECKING RECORDS
//*************** *************** *************** *************** ******

void trans :: report()
{
int choice;
do
{
ab1 : clrscr();
header() ;
cout<<"\n\n\n\n \t\t\t REPORT MENU";
cout<<"\n\t\t\t -----------";
cout<<"\n\t\t\t 1: LIST OF MOVIES ";
cout<<"\n\t\t\t 2: LIST OF MOVIES TO BE RETURNED ";
cout<<"\n\t\t\t 3: LIST OF MOVIES AVALAIBLE";
cout<<"\n\t\t\t 4: RETURN TO MAIN MENU ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch (choice)
{
case 1: clrscr();
header();
t1.dheader();
t1.lmdisplay();
getch();
break;
case 2: clrscr();
header();
t1.cheader();
t1.lmrdisplay() ;
getch() ;
break;
case 3: clrscr();
header();
t1.d1header();
t1.lmadisplay() ;
getch();
break;
case 4: break;
default: cout<<"\n\n\n\n \n\n\t\t\t INVALID CHOICE !!!!!!!!! ";
getch();
goto ab1;
}
}while(choice>= 1 && choice<4);
}
void trans :: dheader()
{
gotoxy(2,4);
cout<<"MOVIE CODE NAME LANGUAGE VIDEO TYPE ";
gotoxy(2,5);
cout<<"---------- ---- -------- ---------- ";
}
void trans :: lmdisplay()
{
int n=5;
fstream mfile;
mfile.open("mov ie.dat",ios::in );
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
n+=1;
gotoxy(7,n);
cout<<m1.mcode;
gotoxy(16,n);
puts(m1.mname);
gotoxy(37,n);
puts(m1.mlang);
gotoxy(50,n);
puts(m1.vtype);
cout<<endl;
mfile.read((cha r*)&m1, sizeof(m1));
}
mfile.close();
}
void trans :: d1header()
{
gotoxy(2,4);
cout<<"MOVIE CODE MOVIE NAME VIDEO TYPE ";
gotoxy(2,5);
cout<<"---------- ---------- ---------- ";
}
void trans :: lmadisplay()
{
int n=5;
fstream mfile;
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if(m1.issued==' f')
{
n+=1;
gotoxy(7,n);
cout<<m1.mcode;
gotoxy(16,n);
puts(m1.mname);
gotoxy(42,n);
puts(m1.vtype);
cout<<endl ;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
}
void trans :: cheader()
{
gotoxy(2,4);
cout<<"CUSTOMER NAME MOVIE ISSUED ISSUE DATE RETURN DATE ";
gotoxy(2,5);
cout<<"------------- ------------ ----------
----------- ";
}
void trans :: lmrdisplay()
{
int n=5;
fstream cfile;
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1,sizeof(t 1));
while(!cfile.eo f())
{
n+=1;
gotoxy(2,n);
puts(t1.cname);
gotoxy(20,n);
puts(t1.mname);
gotoxy(43,n);
cout<<curr_date .dd<<"/"<<curr_date.mm <<"/"<<curr_date.yy yy;
gotoxy(57,n);
cout<<ret_date. dd<<"/"<<ret_date.mm< <"/"<<ret_date.yyy y;
cout<<endl ;
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
int validate(date1 &da)
{
int flag=1;
struct dosdate_t d;
_dos_getdate(&d );
if(da.yyyy!=d.y ear)
{
flag=0;
return flag;
}
else
{
if((da.yyyy<=0) ||(da.mm<=0)||( da.dd<=0))
flag=0;
else
{
switch (da.mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:flag=t1.chec k_day(da.dd,31) ;
break;
case 4 :
case 6 :
case 9 :
case 11: flag=t1.check_d ay(da.dd,30);
break;
case 2 : if((da.yyyy%4== 0))
flag=t1.check_d ay(da.dd,29);
else
flag=t1.check_d ay(da.dd,28);
break;
default: flag=0;
}
}
return flag;
}
}
void trans :: retdate()
{
char ch;
switch (curr_date.mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:show_date(cu rr_date.dd,curr _date.mm,curr_d ate.yyyy,31);
break;
case 4 :
case 6 :
case 9 :
case 11:show_date(cu rr_date.dd,curr _date.mm,curr_d ate.yyyy,30);
break;
case 2 : if((curr_date.y yyy%4==0))
show_date(curr_ date.dd,curr_da te.mm,curr_date .yyyy,29);
else
show_date(curr_ date.dd,curr_da te.mm,curr_date .yyyy,28);
break;
}
}
void trans :: show_date(int date,int mm,int yyyy,int lastd)
{
int rdate=t1.days;
rdate+=date;
if(rdate>lastd && mm==12)
{
mm=1;
cout<< (rdate-=lastd) <<"/"<<mm<<"/"<< (yyyy+=1) ;
getch();
}
else
{
if(rdate>lastd)
{
cout<< (rdate-=lastd) <<"/"<<(mm+=1)< <"/"<<yyyy;
getch();
}
else
{
cout<<rdate<<"/"<<mm<<"/"<<yyyy;
getch();
}
}
ret_date.dd=rda te;
ret_date.mm=mm;
ret_date.yyyy=y yyy;
}
int trans :: check_day(int day,int lastd)
{
if ((day>=1)&&(day <=lastd))
return 1;
else
return 0;
}

//*************** *************** *************** *************** *************** *
//CODE TO PRINT A BOX
//*************** *************** *************** *************** *************** *

void line_hor(int col1,int col2,int row, char c)
{
for(col1;col1<= col2;col1++)
{
gotoxy(col1,row );
cout<<c;
}
}
void line_ver(int row1,int row2,int col,char c)
{
for(row1;row1<= row2;row1++)
{
gotoxy(col,row1 );
cout<<c;
}
}
void print_box()
{
clrscr();
line_hor(1,79,1 ,219);
line_hor(1,79,2 5,219);
line_ver(1,25,1 ,219);
line_ver(1,25,7 9,219);
delay(50);
line_hor(2,78,2 ,219);
line_hor(2,78,2 4,219);
line_ver(2,24,2 ,219);
line_ver(2,24,7 8,219);
delay(50);
line_hor(3,77,3 ,219);
line_hor(3,77,2 3,219);
line_ver(3,23,3 ,219);
line_ver(3,23,7 7,219);
delay(50);
line_hor(4,76,4 ,178);
line_hor(4,76,2 2,178);
line_ver(4,22,4 ,178);
line_ver(4,22,7 6,178);
delay(50);
line_hor(5,75,5 ,178);
line_hor(5,75,2 1,178);
line_ver(5,21,5 ,178);
line_ver(5,21,7 5,178);
delay(50);
line_hor(6,74,6 ,178);
line_hor(6,74,2 0,178);
line_ver(6,20,6 ,178);
line_ver(6,20,7 4,178);
delay(50);
line_hor(7,73,7 ,177);
line_hor(7,73,1 9,177);
line_ver(7,19,7 ,177);
line_ver(7,19,7 3,177);
delay(50);
line_hor(8,72,8 ,177);
line_hor(8,72,1 8,177);
line_ver(8,18,8 ,177);
line_ver(8,18,7 2,177);
delay(50);
line_hor(9,71,9 ,177);
line_hor(9,71,1 7,177);
line_ver(9,17,9 ,177);
line_ver(9,17,7 1,177);
delay(50);
line_hor(10,70, 10,178);
line_hor(10,70, 16,178);
line_ver(10,16, 10,178);
line_ver(10,16, 70,178);
delay(50);
line_hor(11,69, 11,178);
line_hor(11,69, 15,178);
line_ver(11,15, 11,178);
line_ver(11,15, 69,178);
delay(50);
_setcursortype( _NOCURSOR);
gotoxy(30,13);
textcolor(GREEN +BLINK);
cprintf("VIDEO LIBRARY SYSTEM");
getch();
gotoxy(30,13);
clreol() ;
textcolor(WHITE );
pass();
textcolor(WHITE );
}

//*************** *************** *************** *************** *************** ***
//CODE TO ACCEPT THE PASSWORD
//*************** *************** *************** *************** *************** ***

void pass()
{
char pass[]={"videolib"} ;
int s=strlen(pass);
char pass1[10];
int count=0;
clrscr();
line_hor(1,79,1 ,219);
line_hor(1,79,2 5,219);
line_ver(1,25,1 ,219);
line_ver(1,25,7 9,219);
delay(50);
line_hor(2,78,2 ,219);
line_hor(2,78,2 4,219);
line_ver(2,24,2 ,219);
line_ver(2,24,7 8,219);
delay(50);
line_hor(3,77,3 ,219);
line_hor(3,77,2 3,219);
line_ver(3,23,3 ,219);
line_ver(3,23,7 7,219);
delay(50);
line_hor(4,76,4 ,178);
line_hor(4,76,2 2,178);
line_ver(4,22,4 ,178);
line_ver(4,22,7 6,178);
delay(50);
line_hor(5,75,5 ,178);
line_hor(5,75,2 1,178);
line_ver(5,21,5 ,178);
line_ver(5,21,7 5,178);
delay(50);
line_hor(6,74,6 ,178);
line_hor(6,74,2 0,178);
line_ver(6,20,6 ,178) ;
line_ver(6,20,7 4,178);
delay(50);
line_hor(7,73,7 ,177);
line_hor(7,73,1 9,177);
line_ver(7,19,7 ,177);
line_ver(7,19,7 3,177);
delay(50);
line_hor(8,72,8 ,177);
line_hor(8,72,1 8,177);
line_ver(8,18,8 ,177);
line_ver(8,18,7 2,177);
delay(50);
line_hor(9,71,9 ,177);
line_hor(9,71,1 7,177);
line_ver(9,17,9 ,177);
line_ver(9,17,7 1,177);
delay(50);
line_hor(10,70, 10,178);
line_hor(10,70, 16,178);
line_ver(10,16, 10,178);
line_ver(10,16, 70,178);
delay(50);
line_hor(11,69, 11,178);
line_hor(11,69, 15,178);
line_ver(11,15, 11,178);
line_ver(11,15, 69,178);
delay(50);
gotoxy(27,13);
cout<<"ENTER THE PASSWORD:";
ll : for (int i=0; i<s; i++)
{
pass1[i]=getch();
cout<<"*";
}
if(strcmp(pass, pass1)==0)
{
count++;
return;
}
else
{
if(strcmp(pass, pass1)!=0)
{
gotoxy(27,13);
textcolor(RED+B LINK);
cprintf("SORRY! INVALID PASSWORD!!!!!") ;
textcolor(WHITE );
getch() ;
exit(0) ;
}
}
}
void print_box();

void header();

//*************** *************** *************** *************** *****
//main() starts from here
//*************** *************** *************** *************** *****

void main()
{
print_box();
clrscr();
int choice;
do
{
again : clrscr();
header();
cout<<"\n\n\n\n \t\t\t MAIN MENU ";
cout<<"\n\t\t\t --------- ";
cout<<"\n\t\t\t 1: REGISTER A NEW MOVIE ";
cout<<"\n\t\t\t 2: SEARCH FOR A MOVIE ";
cout<<"\n\t\t\t 3: MODIFY INFO OF A MOVIE ";
cout<<"\n\t\t\t 4: ISSUE A MOVIE ";
cout<<"\n\t\t\t 5: RETURN A MOVIE ";
cout<<"\n\t\t\t 6: DELETE A MOVIE ";
cout<<"\n\t\t\t 7: ADD A VIDEO TYPE ";
cout<<"\n\t\t\t 8: REPORTS ";
cout<<"\n\t\t\t 9: EXIT ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch (choice)
{
case 1 : m1.madd();
break;
case 2 : clrscr();
header();
m1.msearch();
getch () ;
break;
case 3 : clrscr();
header();
m1.modify();
break;
case 4 : clrscr();
header();
t1.cuadd();
break;
case 5 : clrscr();
header();
t1.search_menu( );
getch () ;
break;
case 6 : clrscr();
header();
m1.mdelete();
getch();
break;
case 7 : clrscr();
header();
v1.vadd();
break;
case 8 : t1.report();
break;
case 9 : clrscr();
exit(0);
default : cout<<"\n\n\n\n \n\t\t\t INVALID CHOICE !!!!!!! ";
getch () ;
goto again;
}
}while(choice>= 1&&choice<=9) ;
}
void header()
{
gotoxy(25,1);
cout<<" VIDEO LIBRARY SYSTEM "<<endl;
gotoxy(25,2);
cout<<" -------------------- ";
}

Jul 23 '05 #1
3 2717
I'm pretty sure you don't mind to tell us the menu selections leading
to the
error and to provide more detail on the error itself.

BTW: your determination of a leap year is wrong:
bool leapyear(int yy)
{
return yy % 4 == 0 && yy % 100 != 0 || yy % 400 == 0;
}

regards
Stephan Brönnimann
br****@osb-systems.com
Open source rating and billing engine for communication networks.

Jul 23 '05 #2
"Abhas" writes:

<scroll to end>
> I had made a video library program in C++, but was facing a problem.
> After entering 12 movies, i cannot enter any more movies.
> Something gibberish comes instead.
> Can somebody please tell whats wrong??
> This is the code : :

#include<fstrea m.h>
#include<conio. h>
#include<stdio. h>
#include<proces s.h>
#include<string .h>
#include<dos.h>

/*
USE OF HEADER FILES :
FSTREAM.H = FOR DATABASE MANAGEMENT(STRE AMS ETC...), IOSTREAM.H
CONIO.H = FOR TEXTCOLOR, CLRSCR(), GETCH() ETC...
STDIO.H = RENAME, REMOVE, GETS(), PUTS() ETC...
PROCESS.H = FOR EXIT()
STRING.H = FOR STRING RELATED FUNCTIONS
DOS.H = FOR _DOS_GETDATE FUNCTION
*/

void pass(); //TO INPUT A PASSWORD TO ACCESS THE PROGRAM

struct date1
{
int dd, mm, yyyy;
};
struct dosdate_t d; //TO GET CURRENT DATE

//*************** *************** *************** *************
//CLASS TO MAINTAIN MOVIE FILE
//*************** *************** *************** *************

class movie
{
public:
int mcode;
char mlang[20];
int mrelease;
char vtype[10];
char mname[40];
char issued;
movie (); //CONSTRUCTOR
int rec_no();
void input();
void display();
void modify();
friend void header(); //FRIEND FUNCTION
friend char upper(char*); //FRIEND FUNCTION
void madd();
void mshow();
void msearch();
void modmovie();
void modyear();
void modlang();
void modstat(char,ch ar []);
int movieissued(cha r[]);
void mdelete();
} m1;
movie :: movie()
{
issued='f'; //ASSIGNS FALSE FIELD FOR UNISSUED MOVIES
}
int movie :: rec_no()
{
fstream mfile;
int recno;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0,i os::end);
int n=mfile.tellg() ;
mfile.close();
if (n<=0||mfile.eo f())
{
recno=1;
return recno;
}
else
{
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
recno=m1.mcode;
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
return (recno+1);
}
}
int movie :: movieissued(cha r mname[])
{
fstream mfile;
int found;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,mname)==0) )
{
if(m1.issued==' f')
{
found=0;
}
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
return found;
}
void movie :: input()
{
cout<<"\n\t\t MOVIE CODE : ";
cout<<mcode<<en dl ;
cout<<"\t\t ENTER THE MOVIE NAME : ";
gets(mname);
cout<<"\t\t ENTER THE MOVIE LANGUAGE : ";
cin>>mlang;
cout<<"\t\t ENTER THE RELEASE YEAR : ";
cin>>mrelease;
cout<<"\t\t ENTER THE VIDEO TYPE (CD/DVD/CASSETTE) : ";
cin>>vtype;
cout<<"\t\t ISSUED : ";
cout<< m1.issued;
}

//*************** *************** *************** *************** *****
//CODE FOR ADDING NEW MOVIES TO THE FILE
//*************** *************** *************** *************** *****

void movie :: madd()
{
fstream mfile;
char ans='y';
mcode=rec_no();
mfile.open("mov ie.dat",ios::ou t|ios::app) ;
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\n\n \t\t\t MOVIE DETAILS "<<endl;
cout<<"\t\t\t -------------"<< endl;
m1.input();
mfile.write((ch ar*)&m1,sizeof( m1));
mcode=mcode+1;
cout<<"\n\t\t CONTINUE (Y/N) : ";
cin>>ans ;
}
mfile.close();
}
void movie :: mshow()
{
fstream mfile;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
m1.display();
cout<<endl ;
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
}
void movie :: display()
{
cout<<"\n\t\t\t MOVIE CODE : ";
cout<<mcode<<en dl ;
cout<<"\t\t\t MOVIE NAME : ";
puts(mname);
cout<<"\t\t\t MOVIE LANGUAGE : ";
cout<<mlang;
cout<<"\n\t\t\t RELEASE YEAR : ";
cout<<mrelease;
cout<<"\n\t\t\t VIDEO TYPE : ";
cout<<vtype;
cout<<"\n\t\t\t ISSUED : ";
cout<<m1.issued ;
}

//*************** *************** *************** **********
//CODE TO SEARCH FOR A MOVIE
//*************** *************** *************** **********

void movie :: msearch()
{
fstream mfile;
char m[20];
int counter=0;
cout<<"\n\n\n\t \tENTER THE MOVIE TO BE SEARCHED:";
gets(m);
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,m)==0))
{
counter++;
m1.display();
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
if (counter==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
textcolor(WHITE );
}
}

//*************** *************** *************** ************
// CODE FOR MODIFYING INFO OF A MOVIE IN A FILE
//*************** *************** *************** ************

void movie :: modify()
{
int ch;
do
{
aa: clrscr();
header();
cout<<"\n\n\n\n \t\t\t MODIFY MENU ";
cout <<"\n\t\t\t ---------- ";
cout<<"\n\t\t\t 1: MODIFY MOVIE NAME ";
cout<<"\n\t\t\t 2: MODIFY RELEASE YEAR ";
cout<<"\n\t\t\t 3: MODIFY LANGUAGE ";
cout<<"\n\t\t\t 4: RETURN TO MAIN MENU";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>ch;
switch(ch)
{
case 1 : clrscr();
header();
m1.modmovie();
break;
case 2 : clrscr();
header();
m1.modyear();
break;
case 3 : clrscr();
header();
m1.modlang();
break;
case 4 : break;
default : cout<<"\n\n\n\n \n\n\n\t\t\t INVALID CHOICE !!!!!!!!! ";
getch();
goto aa;
}
} while(ch>1 && ch<4);
}
void movie :: modmovie()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout<<"\n\n\t\t ENTER THE MOVIE NAME TO BE MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t ENTER THE NAME: ";
gets(m1.mname);
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}
void movie :: modyear()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout<<"\n\n\t ENTER THE MOVIE NAME IN WHICH YEAR IS TO BE MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t \t ENTER THE YEAR:";
cin>>m1.mreleas e;
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}
void movie :: modlang()
{
fstream mfile;
int found=0;
char name[20];
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
cout <<"\n\n\t ENTER THE MOVIE NAME IN WHICH LANGUAGE TO BE
MODIFIED:";
gets(name);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
cout<<"\n\n\t\t ENTER THE LANGUAGE: ";
gets(m1.mlang);
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
found=1;
break;
}
mfile.read((cha r*)&m1,sizeof (m1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch () ;
textcolor(WHITE );
}
mfile.close();
}

//*************** *************** *************** ***************
//MODIFIES THE STATUS ON RETURNING A MOVIE
//*************** *************** *************** ***************

void movie :: modstat(char ch,char name[])
{
int found =0;
fstream mfile;
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name))==0)
{
m1.issued=ch;
found++;
int n=mfile.tellg() ;
mfile.seekg(n-sizeof(m1));
mfile.write((ch ar*)&m1,sizeof( m1));
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
if (found==0)
{
gotoxy(27,25);
textcolor(WHITE +BLINK);
cprintf("MOVIE NOT FOUND !!!!");
getch();
textcolor(WHITE );
}
mfile.close();
}

//*************** *************** *************** *************** **
//CODE FOR DELETING A MOVIE
//*************** *************** *************** *************** **

void movie :: mdelete()
{
fstream mfile,m1file;
char mname[20];
int count=0;
cout<<" \n\n\t\t\tENTER THE MOVIE TO BE DELETED: ";
gets(mname);
mfile.open("mov ie.dat",ios::in );
m1file.open("mo vie1.dat",ios:: app|ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if(strcmp(m1.mn ame, mname)!=0)
{
m1file.write((c har*)&m1,sizeof (m1));
count++;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
m1file.close();
remove("movie.d at");
rename("movie1. dat","movie.dat ");
if (count!=0)
{
gotoxy(27,25);
textcolor(RED+B LINK);
cprintf(" MOVIE DELETED !!!!");
textcolor(WHITE );
}
}

//*************** *************** *************** ***************
//CLASS FOR MAINTAINING VIDEO PRICES
//*************** *************** *************** ***************

class video
{
char vtype[15];
float vprice;
float vexch;
protected:
int vcode;
public:
void vinput();
void vdisplay();
void vadd();
int type_exist(char[]);
int type_check(char[]);
int rec_no();
int calexcharges(ch ar [],int);
}v1;
int video :: calexcharges(ch ar name[],int i)
{
fstream mfile,vfile;
char type[10];
int ch;
mfile.open("mov ie.dat",ios::in );
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if((strcmp(m1.m name,name)==0))
{
strcpy(type,m1. vtype);
}
mfile.read((cha r*)&m1,sizeof(m 1));
}

vfile.open("vid eo.dat",ios::in );
vfile.seekg(0, ios::beg);
vfile.read((cha r*)&v1,sizeof(v 1));
while(!vfile.eo f())
{
if((strcmp(type ,v1.vtype)==0))
{
ch=v1.vexch;
}
vfile.read((cha r*)&v1,sizeof(v 1));
}
mfile.close();
vfile.close();
int exch=ch*i;
return exch;
}
void video :: vinput()
{
int check, found;
cout<<"\n\t\t ENTER THE VIDEO CODE :";
cin<<vcode;
cout<<"\t\t ENTER THE VIDEO TYPE (CD/DVD/CASSETTE) :";
cin>>vtype;
cout<<"\t\t ENTER THE VIDEO PRICE :Rs. ";
cin>>vprice;
cout<<"\t\t ENTER THE EXTRA CHARGES(PER DAY) :Rs. ";
cin>>vexch;
}

//*************** *************** *************** **************
//CODE FOR ADDING VIDEO TYPE TO A FILE
//*************** *************** *************** **************

void video :: vadd()
{
fstream vfile;
char ans='y';
vfile.open("vid eo.dat",ios::in |ios::app);
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\n\t \t\t VIDEO DETAILS";
cout<<"\n\t\t\t -------------";
v1.vinput();
vfile.write((ch ar*)&v1,sizeof( v1));
vcode=vcode+1;
cout<<"\t\t CONTINUE (Y/N) :";
cin>>ans;
}
vfile.close();
}

//*************** *************** *************** *************** **
//CLASS TRANSACTION:
// FOR MAINTAINING CUSTOMER FILE AND RELATED RECORDS
//*************** *************** *************** *************** **

class trans : public movie, public video
{
date1 curr_date,ret_d ate;
int id;
char cname[20];
char cadd[40];
float charges;
int days;
int nddays;
char ch;
public:
int cinput();
void cuadd();
void mcdisplay(char []);
void cdisplay(char []);
int rec_no();
void report();
void cdelete(char[]);
void search_menu();
void mcsearch();
void csearch();
void dheader();
void lmdisplay();
void d1header();
void lmadisplay();
void cshow();
void cheader();
void lmrdisplay();
int check_day(int,i nt);
void retdate();
void show_date(int,i nt,int,int);
void ddays();
int showdays(int,in t);
friend int validate(date1 &da);
}t1;
int trans :: rec_no ()
{
fstream cfile;
int rno;
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
int n=cfile.tellg() ;
cfile.close() ;
if (n<=0||cfile.eo f())
{
rno=1;
return rno;
}
else
{
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1,sizeof(t 1));
while(!cfile.eo f())
{
rno=t1.id;
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
return (rno+1);
}
}
int trans :: cinput()
{
int k;
cout<<"\n\t\t CUSTOMER ID : ";
cout<<id<<endl;
cout<<"\t\t ENTER THE CUSTOMER NAME : ";
gets(cname);
cout<<"\t\t ENTER THE ADDRESS : ";
gets(cadd);
cout<<"\t\t ENTER THE MOVIE NAME : ";
gets(mname);
k=m1.movieissue d(mname);
if (k==0)
{
m1.modstat('t', mname);
cout<<"\t\t ENTER THE MOVIE CHARGES : Rs. ";
cin>>charges;
cout<<"\t\t ENTER NO.OF DAYS,MOVIE ISSUED : ";
cin>>days;
cout<<"\t\t ENTER THE ISSUE DATE(dd/mm/yyyy): ";
ll: cin>>curr_date. dd>>ch;
cin>>curr_date. mm>>ch;
cin>>curr_date. yyyy;
if (validate(curr_ date)==0)
{
gotoxy(27,22);
textcolor(WHITE +BLINK);
cprintf("INVALI D DATE!!! ");
getch() ;
textcolor(WHITE );
gotoxy(27,22);
clreol();
gotoxy(56,12);
clreol();
goto ll;
}
cout<<"\t\t RETURN DATE : ";
retdate();
cout<<"\t\t\t\t \tISSUED(T/F) : ";
cin>>issued;
}
else
{
gotoxy(25,20);
textcolor(WHITE +BLINK);
cprintf("MOVIE ALREADY ISSUED OR DOES NOT EXIST");
getch() ;
textcolor(WHITE );
gotoxy(25,20);
clreol();
}
return k;
}

//*************** *************** *************** *************** *********
//CODE FOR ADDING CUSTOMER RECORD TO A FILE OR ISSUE A MOVIE
//*************** *************** *************** *************** *********

void trans :: cuadd()
{
int aa;
fstream cfile;
char ans='y';
id=rec_no();
cfile.open("cus t.dat",ios::out |ios::app) ;
while(ans=='y')
{
clrscr();
header();
cout<<"\n\n\t\t \t ISSUE DETAILS";
cout<<"\n\t\t\t -------------" ;
aa=t1.cinput();
if(aa==0)
{
cfile.write((ch ar*)&t1,sizeof( t1));
id=id+1;
}
cout<<"\n\t\t\t CONTINUE (Y/N) : ";
cin>>ans;
}
cfile.close();
}
void trans :: cdisplay(char name[])
{
int tcharges;
cout<<"\n\t\t\t CUSTOMER ADDRESS : ";
puts(cadd);
cout<<"\t\t\t MOVIE NAME : ";
puts(mname);
cout<<"\t\t\t MOVIE CHARGES : Rs. "<<charges;
cout<<"\n\t\t\t ISSUED DAYS : "<<days;
cout<<"\n\t\t\t ISSUED DATE(DD/MM/YY) :
"<<curr_date.dd <<ch<<curr_date .mm<<ch<<curr_d ate.yyyy;
cout<<"\n\t\t\t RETURN DATE :
"<<ret_date.dd< <ch<<ret_date.m m<<ch<<ret_date .yyyy;
cout<<"\n\t\t\t DUE DAYS : ";
ddays() ;
int exch=calexcharg es(name,t1.ndda ys);
cout<<"\n\t\t\t EXTRA CHARGES : Rs. "<<exch;
tcharges=exch+t 1.charges;
cout<<"\n\t\t\t TOTAL CHARGES : Rs. "<<tcharges ;
}
void trans :: mcdisplay(char name[])
{
int tcharges;
cout<<"\n\t\t\t CUSTOMER NAME : ";
puts(cname);
cout<<"\t\t\t CUSTOMER ADDRESS : ";
puts(cadd);
cout<<"\t\t\t MOVIE CHARGES : Rs. "<<charges;
cout<<"\n\t\t\t ISSUED DAYS : "<<days;
cout<<"\n\t\t\t ISSUED DATE(DD/MM/YY) :
"<<curr_date.dd <<ch<<curr_date .mm<<ch<<curr_d ate.yyyy;
cout<<"\n\t\t\t RETURN DATE :
"<<ret_date.dd< <ch<<ret_date.m m<<ch<<ret_date .yyyy;
cout<<"\n\t\t\t DUE DAYS : ";
ddays() ;
int exch=calexcharg es(name,t1.ndda ys);
cout<<"\n\t\t\t EXTRA CHARGES : Rs. "<<exch;
tcharges=exch+t 1.charges;
cout<<"\n\t\t\t TOTAL CHARGES : Rs. "<<tcharges ;
}
int showdays(int,in t);

void trans :: ddays()
{
struct dosdate_t d;
_dos_getdate(&d );
int ch=0;
int ddays=0;
int mm=ret_date.mm;
if(d.day<=ret_d ate.dd)
{
t1.nddays=ddays ;
cout<<"-";
}
else
{
if(d.month==mm)
{
switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=d.day-ret_date.dd;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=d.day-ret_date.dd;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=d.day-ret_date.dd;
mm++ ;
}
else
{
ddays=d.day-ret_date.dd;
mm++;
}
break;
}
ch++;
}
else
{
switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=31-ret_date.dd;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=30-ret_date.dd;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=29-ret_date.dd;
mm++;
}
else
{
ddays=28-ret_date.dd;
mm++;
}
break;
}
ch++;
}

if(d.year==(ret _date.yyyy+1))
{
if (mm==13)
mm=1;
while(mm<d.mont h)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays=showda ys(ddays,31);
mm++ ;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays=showda ys(ddays,30);
mm++ ;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays=showdays( ddays,29);
mm++ ;
}
else
{
ddays=showdays( ddays,28);
mm++;
}
break;
}
ch++;
}
if (mm==d.month)
goto ll;
}
}
{
if (ret_date.yyyy= =d.year)
{
if(d.month==(re t_date.mm+1))
{
ll: switch (mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=d.day ;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=d.day ;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=d.day;
mm++;
}
else
{
ddays+=d.day;
mm++;
}
break;
}
ch++;
}
else
{
while(mm<d.mont h)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=31;
mm++;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=30;
mm++;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=29;
mm++;
}
else
{
ddays+=28;
mm++;
}
break;
}
if (mm==d.month)
{
switch(mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:ddays+=d.day ;
mm++ ;
break;
case 4 :
case 6 :
case 9 :
case 11:ddays+=d.day ;
mm++ ;
break;
case 2 :if((ret_date.y yyy%4==0))
{
ddays+=d.day;
mm++;
}
else
{
ddays+=d.day;
mm++;
}
break;
}
ch++;
}
}
}
}
t1.nddays=ddays ;
cout<<t1.nddays ;
}
}
int trans :: showdays(int duedays,int lastd)
{
duedays+=lastd;
return duedays;
}

//*************** *************** *************** *************** *************** *****
//CODE FOR SEARCHING A CUSTOMER RECORD AND DELETE IT,IN CASE OF
RETURNING
//THE MOVIE
//*************** *************** *************** *************** *************** *****

void trans :: search_menu()
{
int choice;
do
{
ac: clrscr();
header();
cout<<"\n\n\n\n \t\t\t SEARCH MENU ";
cout<<"\n\t\t\t ----------- ";
cout<<"\n\t\t\t 1: SEARCH BY CUSTOMER NAME ";
cout<<"\n\t\t\t 2: SEARCH BY MOVIE NAME ";
cout<<"\n\t\t\t 3: RETURN TO MAIN MENU ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch(choice)
{
case 1: clrscr();
header();
t1.csearch();
getch();
break;
case 2: clrscr();
header();
t1.mcsearch();
getch() ;
break;
case 3: break;
default: cout <<"\n\n\n\n\n\n \t\t\t INVALID CHOICE !!!!!!!!! ";
getch () ;
goto ac;
}
}while(choice>= 1&&choice<3);
}
void trans :: mcsearch()
{
char ans = 'y';
char name[20] ;
char pname[20];
fstream cfile;
cout<<"\n\t\tEN TER THE MOVIE NAME TO BE SEARCHED: ";
gets(name);
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
while(!cfile.eo f())
{
if((strcmp(t1.m name,name)==0))
{
t1.mcdisplay(na me);
cout<<"\n\n\n\t \t DO YOU WISH TO DELETE?(Y/N): ";
cin>>ans;
if (ans=='y'||ans= ='Y')
{
cdelete(t1.cnam e);
}
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
void trans :: csearch()
{
char ans = 'y' ;
char name[20];
char pname[20];
fstream cfile;
cout<<"\n\t\tEN TER THE CUSTOMER NAME TO BE SEARCHED: ";
gets(name);
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
while(!cfile.eo f())
{
if((strcmp(t1.c name,name)==0))
{
t1.cdisplay(t1. mname);
cout<<"\n\n\n\t \t DO YOU WISH TO DELETE?(Y/N): ";
cin>>ans;
if (ans=='y'||ans= ='Y')
{
cdelete(name);
}
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
void trans :: cdelete(char name[])
{
fstream cfile,c1file;
char cname[20];
cfile.open("cus t.dat",ios::in) ;
c1file.open("cu st1.dat",ios::a pp|ios::out);
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1, sizeof(t1));
while(!cfile.eo f())
{
if(strcmp(t1.cn ame,name)!=0)
{
c1file.write((c har*)&t1,sizeof (t1));
}
else
{
m1.modstat('f', t1.mname);
}
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
c1file.close();
remove("cust.da t");
rename("cust1.d at","cust.dat") ;
}

//*************** *************** *************** *************** ******
//CODE FOR CHECKING RECORDS
//*************** *************** *************** *************** ******

void trans :: report()
{
int choice;
do
{
ab1 : clrscr();
header() ;
cout<<"\n\n\n\n \t\t\t REPORT MENU";
cout<<"\n\t\t\t -----------";
cout<<"\n\t\t\t 1: LIST OF MOVIES ";
cout<<"\n\t\t\t 2: LIST OF MOVIES TO BE RETURNED ";
cout<<"\n\t\t\t 3: LIST OF MOVIES AVALAIBLE";
cout<<"\n\t\t\t 4: RETURN TO MAIN MENU ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch (choice)
{
case 1: clrscr();
header();
t1.dheader();
t1.lmdisplay();
getch();
break;
case 2: clrscr();
header();
t1.cheader();
t1.lmrdisplay() ;
getch() ;
break;
case 3: clrscr();
header();
t1.d1header();
t1.lmadisplay() ;
getch();
break;
case 4: break;
default: cout<<"\n\n\n\n \n\n\t\t\t INVALID CHOICE !!!!!!!!! ";
getch();
goto ab1;
}
}while(choice>= 1 && choice<4);
}
void trans :: dheader()
{
gotoxy(2,4);
cout<<"MOVIE CODE NAME LANGUAGE VIDEO TYPE ";
gotoxy(2,5);
cout<<"---------- ---- -------- ---------- ";
}
void trans :: lmdisplay()
{
int n=5;
fstream mfile;
mfile.open("mov ie.dat",ios::in );
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
n+=1;
gotoxy(7,n);
cout<<m1.mcode;
gotoxy(16,n);
puts(m1.mname);
gotoxy(37,n);
puts(m1.mlang);
gotoxy(50,n);
puts(m1.vtype);
cout<<endl;
mfile.read((cha r*)&m1, sizeof(m1));
}
mfile.close();
}
void trans :: d1header()
{
gotoxy(2,4);
cout<<"MOVIE CODE MOVIE NAME VIDEO TYPE ";
gotoxy(2,5);
cout<<"---------- ---------- ---------- ";
}
void trans :: lmadisplay()
{
int n=5;
fstream mfile;
mfile.open("mov ie.dat",ios::in |ios::out);
mfile.seekg(0, ios::beg);
mfile.read((cha r*)&m1,sizeof(m 1));
while(!mfile.eo f())
{
if(m1.issued==' f')
{
n+=1;
gotoxy(7,n);
cout<<m1.mcode;
gotoxy(16,n);
puts(m1.mname);
gotoxy(42,n);
puts(m1.vtype);
cout<<endl ;
}
mfile.read((cha r*)&m1,sizeof(m 1));
}
mfile.close();
}
void trans :: cheader()
{
gotoxy(2,4);
cout<<"CUSTOMER NAME MOVIE ISSUED ISSUE DATE RETURN DATE ";
gotoxy(2,5);
cout<<"------------- ------------ ----------
----------- ";
}
void trans :: lmrdisplay()
{
int n=5;
fstream cfile;
cfile.open("cus t.dat",ios::in) ;
cfile.seekg(0, ios::beg);
cfile.read((cha r*)&t1,sizeof(t 1));
while(!cfile.eo f())
{
n+=1;
gotoxy(2,n);
puts(t1.cname);
gotoxy(20,n);
puts(t1.mname);
gotoxy(43,n);
cout<<curr_date .dd<<"/"<<curr_date.mm <<"/"<<curr_date.yy yy;
gotoxy(57,n);
cout<<ret_date. dd<<"/"<<ret_date.mm< <"/"<<ret_date.yyy y;
cout<<endl ;
cfile.read((cha r*)&t1,sizeof(t 1));
}
cfile.close();
}
int validate(date1 &da)
{
int flag=1;
struct dosdate_t d;
_dos_getdate(&d );
if(da.yyyy!=d.y ear)
{
flag=0;
return flag;
}
else
{
if((da.yyyy<=0) ||(da.mm<=0)||( da.dd<=0))
flag=0;
else
{
switch (da.mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:flag=t1.chec k_day(da.dd,31) ;
break;
case 4 :
case 6 :
case 9 :
case 11: flag=t1.check_d ay(da.dd,30);
break;
case 2 : if((da.yyyy%4== 0))
flag=t1.check_d ay(da.dd,29);
else
flag=t1.check_d ay(da.dd,28);
break;
default: flag=0;
}
}
return flag;
}
}
void trans :: retdate()
{
char ch;
switch (curr_date.mm)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12:show_date(cu rr_date.dd,curr _date.mm,curr_d ate.yyyy,31);
break;
case 4 :
case 6 :
case 9 :
case 11:show_date(cu rr_date.dd,curr _date.mm,curr_d ate.yyyy,30);
break;
case 2 : if((curr_date.y yyy%4==0))
show_date(curr_ date.dd,curr_da te.mm,curr_date .yyyy,29);
else
show_date(curr_ date.dd,curr_da te.mm,curr_date .yyyy,28);
break;
}
}
void trans :: show_date(int date,int mm,int yyyy,int lastd)
{
int rdate=t1.days;
rdate+=date;
if(rdate>lastd && mm==12)
{
mm=1;
cout<< (rdate-=lastd) <<"/"<<mm<<"/"<< (yyyy+=1) ;
getch();
}
else
{
if(rdate>lastd)
{
cout<< (rdate-=lastd) <<"/"<<(mm+=1)< <"/"<<yyyy;
getch();
}
else
{
cout<<rdate<<"/"<<mm<<"/"<<yyyy;
getch();
}
}
ret_date.dd=rda te;
ret_date.mm=mm;
ret_date.yyyy=y yyy;
}
int trans :: check_day(int day,int lastd)
{
if ((day>=1)&&(day <=lastd))
return 1;
else
return 0;
}

//*************** *************** *************** *************** *************** *
//CODE TO PRINT A BOX
//*************** *************** *************** *************** *************** *

void line_hor(int col1,int col2,int row, char c)
{
for(col1;col1<= col2;col1++)
{
gotoxy(col1,row );
cout<<c;
}
}
void line_ver(int row1,int row2,int col,char c)
{
for(row1;row1<= row2;row1++)
{
gotoxy(col,row1 );
cout<<c;
}
}
void print_box()
{
clrscr();
line_hor(1,79,1 ,219);
line_hor(1,79,2 5,219);
line_ver(1,25,1 ,219);
line_ver(1,25,7 9,219);
delay(50);
line_hor(2,78,2 ,219);
line_hor(2,78,2 4,219);
line_ver(2,24,2 ,219);
line_ver(2,24,7 8,219);
delay(50);
line_hor(3,77,3 ,219);
line_hor(3,77,2 3,219);
line_ver(3,23,3 ,219);
line_ver(3,23,7 7,219);
delay(50);
line_hor(4,76,4 ,178);
line_hor(4,76,2 2,178);
line_ver(4,22,4 ,178);
line_ver(4,22,7 6,178);
delay(50);
line_hor(5,75,5 ,178);
line_hor(5,75,2 1,178);
line_ver(5,21,5 ,178);
line_ver(5,21,7 5,178);
delay(50);
line_hor(6,74,6 ,178);
line_hor(6,74,2 0,178);
line_ver(6,20,6 ,178);
line_ver(6,20,7 4,178);
delay(50);
line_hor(7,73,7 ,177);
line_hor(7,73,1 9,177);
line_ver(7,19,7 ,177);
line_ver(7,19,7 3,177);
delay(50);
line_hor(8,72,8 ,177);
line_hor(8,72,1 8,177);
line_ver(8,18,8 ,177);
line_ver(8,18,7 2,177);
delay(50);
line_hor(9,71,9 ,177);
line_hor(9,71,1 7,177);
line_ver(9,17,9 ,177);
line_ver(9,17,7 1,177);
delay(50);
line_hor(10,70, 10,178);
line_hor(10,70, 16,178);
line_ver(10,16, 10,178);
line_ver(10,16, 70,178);
delay(50);
line_hor(11,69, 11,178);
line_hor(11,69, 15,178);
line_ver(11,15, 11,178);
line_ver(11,15, 69,178);
delay(50);
_setcursortype( _NOCURSOR);
gotoxy(30,13);
textcolor(GREEN +BLINK);
cprintf("VIDEO LIBRARY SYSTEM");
getch();
gotoxy(30,13);
clreol() ;
textcolor(WHITE );
pass();
textcolor(WHITE );
}

//*************** *************** *************** *************** *************** ***
//CODE TO ACCEPT THE PASSWORD
//*************** *************** *************** *************** *************** ***

void pass()
{
char pass[]={"videolib"} ;
int s=strlen(pass);
char pass1[10];
int count=0;
clrscr();
line_hor(1,79,1 ,219);
line_hor(1,79,2 5,219);
line_ver(1,25,1 ,219);
line_ver(1,25,7 9,219);
delay(50);
line_hor(2,78,2 ,219);
line_hor(2,78,2 4,219);
line_ver(2,24,2 ,219);
line_ver(2,24,7 8,219);
delay(50);
line_hor(3,77,3 ,219);
line_hor(3,77,2 3,219);
line_ver(3,23,3 ,219);
line_ver(3,23,7 7,219);
delay(50);
line_hor(4,76,4 ,178);
line_hor(4,76,2 2,178);
line_ver(4,22,4 ,178);
line_ver(4,22,7 6,178);
delay(50);
line_hor(5,75,5 ,178);
line_hor(5,75,2 1,178);
line_ver(5,21,5 ,178);
line_ver(5,21,7 5,178);
delay(50);
line_hor(6,74,6 ,178);
line_hor(6,74,2 0,178);
line_ver(6,20,6 ,178) ;
line_ver(6,20,7 4,178);
delay(50);
line_hor(7,73,7 ,177);
line_hor(7,73,1 9,177);
line_ver(7,19,7 ,177);
line_ver(7,19,7 3,177);
delay(50);
line_hor(8,72,8 ,177);
line_hor(8,72,1 8,177);
line_ver(8,18,8 ,177);
line_ver(8,18,7 2,177);
delay(50);
line_hor(9,71,9 ,177);
line_hor(9,71,1 7,177);
line_ver(9,17,9 ,177);
line_ver(9,17,7 1,177);
delay(50);
line_hor(10,70, 10,178);
line_hor(10,70, 16,178);
line_ver(10,16, 10,178);
line_ver(10,16, 70,178);
delay(50);
line_hor(11,69, 11,178);
line_hor(11,69, 15,178);
line_ver(11,15, 11,178);
line_ver(11,15, 69,178);
delay(50);
gotoxy(27,13);
cout<<"ENTER THE PASSWORD:";
ll : for (int i=0; i<s; i++)
{
pass1[i]=getch();
cout<<"*";
}
if(strcmp(pass, pass1)==0)
{
count++;
return;
}
else
{
if(strcmp(pass, pass1)!=0)
{
gotoxy(27,13);
textcolor(RED+B LINK);
cprintf("SORRY! INVALID PASSWORD!!!!!") ;
textcolor(WHITE );
getch() ;
exit(0) ;
}
}
}
void print_box();

void header();

//*************** *************** *************** *************** *****
//main() starts from here
//*************** *************** *************** *************** *****

void main()
{
print_box();
clrscr();
int choice;
do
{
again : clrscr();
header();
cout<<"\n\n\n\n \t\t\t MAIN MENU ";
cout<<"\n\t\t\t --------- ";
cout<<"\n\t\t\t 1: REGISTER A NEW MOVIE ";
cout<<"\n\t\t\t 2: SEARCH FOR A MOVIE ";
cout<<"\n\t\t\t 3: MODIFY INFO OF A MOVIE ";
cout<<"\n\t\t\t 4: ISSUE A MOVIE ";
cout<<"\n\t\t\t 5: RETURN A MOVIE ";
cout<<"\n\t\t\t 6: DELETE A MOVIE ";
cout<<"\n\t\t\t 7: ADD A VIDEO TYPE ";
cout<<"\n\t\t\t 8: REPORTS ";
cout<<"\n\t\t\t 9: EXIT ";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
switch (choice)
{
case 1 : m1.madd();
break;
case 2 : clrscr();
header();
m1.msearch();
getch () ;
break;
case 3 : clrscr();
header();
m1.modify();
break;
case 4 : clrscr();
header();
t1.cuadd();
break;
case 5 : clrscr();
header();
t1.search_menu( );
getch () ;
break;
case 6 : clrscr();
header();
m1.mdelete();
getch();
break;
case 7 : clrscr();
header();
v1.vadd();
break;
case 8 : t1.report();
break;
case 9 : clrscr();
exit(0);
default : cout<<"\n\n\n\n \n\t\t\t INVALID CHOICE !!!!!!! ";
getch () ;
goto again;
}
}while(choice>= 1&&choice<=9) ;
}
void header()
{
gotoxy(25,1);
cout<<" VIDEO LIBRARY SYSTEM "<<endl;
gotoxy(25,2);
cout<<" -------------------- ";
}

--------------
I wandered around in your code for a while but reached no firm conclusions.
But I have the *impression* that you want one file to be created for a
collection of movies. All with the same file name. IOW, do you, by chance,
want an *array* of movies - all in one file?

I wouldn't expect you to get much help here. You use non-standard headers,
which means that a lot of users *couldn't* compile your program, even if
they wanted to. You use global variables - a no no. You have no
indentation - at least as viewed on my mail program. There are no really
useful comments. The thing you posted has got a lot of extraneous stuff,
not related to your current problem. The program is improperly structured
since the variables in movie are all public. Some of the names of the
functions look misleading to me. You ignore status values returned from
system functions, such as open().

If my guess is right you need substantial re-thinking and you might want to
start over. If you do, I suggest you start small and grow the program.
Compile often - just because you compile doesn't mean you have to run the
result.
Jul 23 '05 #3
Enter 12 movies in menu no 1.
After that, When I try to enter a movie, it shows some crap in menu no
8-1.
it shows only 12 movies in menu no 8-3.
check for yourself, thats the problem i was facing.
Bye

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2342
by: GAR | last post by:
I recently set up ampache so I can have an mp3 server. I dont like how they display album covers so I decided to try and change it a little. Instead of taking the album cover from the mp3s themselves I want it to just have a file called 'cover.jpg' in the album's direcory where when someone looks at the album the web browser will display that pic. Here is what I have so far... In the template: <img src="albumart.php?id=<?=$album?>"...
3
11817
by: H Brown New To It | last post by:
I am very new to Java. How would you go about making Java program that reads in a fixed length text file and pass the data into a table in an sql table? The text file data looks something like this: 123456John Smith Acme Boxes Inc 100 Someplace Drive 222222Sarah E. ConnorCyberdyne Systems Corp 1 Connorsbane Plaza 333333Martin Fry Care Of: Joseph P Helstrom200 Hive Avenue
2
1581
by: nephish | last post by:
Hey there, i am trying to write an online application using the cgi module. what i want to do is have an html form display a drop-down list and have the values of that list be the lines of text written in a file. this would be updated almost every time the site is visited. i have been sucessful in writing text to a file from an html form. but i need to access this so it can be selected. is there a way to do this? i have found limited info...
14
5439
by: StumpY | last post by:
HI, I have set up a page with a form which appends data to a .csv file on my asp server, this is to enable a limited number of users to add news threads to this file, which contains the data in the following format (date,headline,article); "181003","news title","news article" "171003","older news title","news article" The form adds the data in reverse chronological order with newest at the top of the list. Now I wish to be able to write...
8
5489
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
2
5570
by: Mike | last post by:
Greetings, Having a major problem here. running version 8.2 on win2003 server. The problem I am having is backing up a database seems to get to the last part of the backup and then fails. This brings the whole instance down and it has to be restarted. In addition the job seems to be stuck in the TOOLSDB as if I try to delete the backup job I get "The task is currently running". So I went to the command line and tried "db2 backup database...
5
3892
by: NG | last post by:
Hi, We are having DB2-V7.2 DB on AIX 5.2 machine. Recently we upgraded our system to fixpack 13 and activated activate AIX asynchronous IO function. Our DB is going to crash recovery with this error 0xFFFFF707. I have attached the related details. Any suggestions is much appreciated.
1
7597
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
36
3510
by: felixnielsen | last post by:
What i really wanna do, is defining my own types, it doesnt really matter why. Anyway, i have run into some problems 1) typedef unsigned short U16; U16 test = 0xffffffff; // There should be a limit on this, max value you should be able to asign should be 0xffff // std::cout << test; // result = 0xffff //
0
9975
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9812
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10799
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10446
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7154
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6032
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4255
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3263
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.