c++ project

Upload: ryan-bell

Post on 13-Oct-2015

11 views

Category:

Documents


0 download

DESCRIPTION

c++ project: code for snake game

TRANSCRIPT

//******************************************************* // INCLUDED HEADER FILES //******************************************************* #include"stdio.h" #include"conio.h" #include"fstream.h" #include"stdlib.h" #include"dos.h" #include"string.h" #include"graphics.h" #include"iomanip.h" //******************************************************* // CLASS NAME : BOOK //******************************************************* class book { public: char name[20]; char author[20]; int a; void getdata(); void show(); }; //******************************************************* // FUNCTIONS TO GET AND SHOW DATA //******************************************************* void book::getdata() { cout<

author; fflush(stdin); cout< >a; } void book::show() { cout< name; do { f.read((char *)&b1,sizeof(b1)); if(f.eof()==1) {break;} if(strcmp(b1.name,name)==0) { cout< a; strcpy(b1.name,name); strcpy(b1.author,author); b1.a=a; int l=f.tellg(); f.close(); f.open("book",ios::out|ios::binary|ios::ate); f.seekg(l-sizeof(b1)); f.write((char *)&b1,sizeof(b1)); } }while(f); f.close(); settextstyle(7,0,1); outtextxy(250,410,"Do You Want To Continue:"); ans=getchar(); if(ans=='Y'||ans=='y') {goto z;} else break; } //******************************************************* //CASE : 5 // DETAILS : TO DELETE A BOOKS RECORD //******************************************************* case 5: { clearviewport(); rectangle(10,10,630,470); setbkcolor(BROWN); setcolor(WHITE); char name[20]; f.close(); f.open("video",ios::in|ios::ate|ios::binary); settextstyle(7,0,3); outtextxy(200,30,"DELETING:-"); cout< >name; f.seekg(0); int k=0; do { f.close(); f.open("book",ios::in|ios::ate|ios::binary); f.seekg(k); fflush(stdin); f.read((char *)&b1,sizeof(b1)); if(f.eof()) break; if(strcmp(b1.name,name)==0) { k+=46; continue; } else { f.close(); f.open("book2",ios::out|ios::ate|ios::binary); f.write((char*)&b1, sizeof b1); k+=46; }}while(f); f.close(); remove ("book"); rename ("book2","book"); cout<