sir,please correct the errors in this program and also write the algorithm in this program and give me an introduction to this program.Pls send the error free program,algorithm & introduction before 03/09/2004.thank you

#include<iostream>
#include<iomanip>
#include<stdio>
#include<cstdlib>
#include<cctype>
#include<fstream>
using namespace std;
const int maxchrs=50;
const int items=3;
const short year=0;
const short length=1;
const short shelf=2;
class movies
{
short data[items];
string title ;
bool readmovie(fstream &video)
{
char str[maxchrs];
video.read(str,maxchrs);
title=str;
video.read((char*)data,sizeof(data));
if(!video.eof())
return true;
else
returnfalse;
}
void writemovie(fstream &video)
{
video.write(&title[0],maxchrs);
video.write((char*)data,sizeof(data));
}
public;
void printfile(void)
void add(void)
void del(void)
void change(int index)
void newfile(void)
};
void newfile(void)
{
fstream video;
video.open("VIDEOS.DAT",ios::out|ios::binary);
title="Nammal";
data[year]=2002;data[lenth]=95;data[shelf]=265;
write movie(video);
title="four the people";
data[year]=2003;data[lenth]=88;data[shelf]=300;
write movie(video);
title="runway";
data[year]=2004;data[lenth]=75;data[shelf]=550;
write movie(video);
video.close()
}
int main(void)
{
movies movie;
char choice;
movie.newfile();
fstream video;
video.open("video file missing"<<endl;
exit(EXIT_FAILURE);
}
video.close();
do
{
cout<<"Do you want to:      change:\n";
cout<<"[A]dd a video?       A[T]itle?\n";
cout<<"[D]elete a video?    A[Y]ear?\n";
cout<<"[p]rint the list?    A[L]ength? \n";
cout<<"[Q]uit ?             A[S]helf position?\n";
cout<<"Take your choice:";
cin>>choice;
cin.ignore(500,'\n');
switch(toupper(choice))
{
case 'A':
movie.add();
break;
case'D':
movie.del();
break;
case'T':
movie.change(-1);
break;
case'y':
movie.change(year);
break;
case'L':
movie.change(length);
break;
case's':
movie.change(shelf);
break;
case'p':
movie.printfile();
}
}
while(toupper(choice)!='Q');
return 0;
}
void printfile(void)
{
fstream video;
short index;
video.open("VIDEOS.DAT",ios::in|ios::binary);
cout<<"\n YEAR  LEN  SHELF  TITLE  \n";
while(readmovie(video))
{
for(index=0;index<items;++index)
cout<<setw(6)<<data[index];
cout<<"  "<<title<<endl;
}
cout<<endl;
video.close();
}
void add(void)
{
fstream video;
movies newmovie;
int recLen=maxchrs+sizeof(data);
long pos;
video.open("VIDEOS.DAT",ios::in|ios::binary);
cout<<"new title:";
getline(cin,new movie.title,'\n');
cout<<"year,length,shelfposition:";
cin>>newmovie.data[year]>>newmovie.data[length]
>>newmovie.data[shelf];
cin.ignore(500,'\n');
video.seekg(-recLen,ios::end);
readmovie(video);
while(newmovie.title < title && pos > 0)
{
writemovie(video);
pos=recLen;
if(pos>0)
{
video.seekg(pos-recLen,ios::beg);
readmovie(video);
}
}
video.seekg(pos,ios::beg);
newmovie.writemovie(video);
video.close();
}
void del(void)
{
fstream video;
fstream temp;
string deltitle;
char answer;
video.open("VIDEOS.DAT",ios::in|ios::binary);
temp.open("TEMP.$TM",ios::out|ios::binary);
cout<<"Deletetitle:";
getline(cin,deltitle,'\n');
while(readmovie(video))
{
answer='N';
if
(deltitle==title.substr(0,deltitle.size()))
{
cout<<"Delete"<<title<<"?";
cin>>answer;
cin.ignore(500,'\n');
}
if(toupper(answer)!='y')
writemovie(temp);
else
deltitle='~";
}
void change(int index)
{
fstream video;
string chtitle;
char answer;
video.open("VIDEOS.DAT",ios::in|ios::out|ios::binary);
cout<<"change title:";
getline(cin,chtitle,'\n');
while(readmovie(video))
{
if
(chtitle==title.substr(0,chtitle.size()))
{
cout<<"change"<<title<<"?";
cin>>answer;
cin.ignore(500,'\n');
if(toupper(answer)=='y')
{
if (index==-1)
{
cout<<"To:";
getline(cin,title,'\n');
}
else
{
cout<<"change"<<data[index]<<"to:";
cin>>data[index];
cin.ignore(500,'\n');
}
video.seekg(-maxchrs+sizeof(data)),ios::cur);
writemovie(video);
video.seekg(0,ios::end);
}
}
}


video.close();
}

Recommended Answers

All 4 Replies

Ha ha ha ha. Funny! Ok, I'll bite...

Introduction:
This program moves data from one portion of the computer's memory to another, activates some peripheral devices, and attempts to communicate with a human, albeit cryptically.

Algorithm:
For each instruction in the program, execute the instructions in order, except for branches, until the program is complete.

You made my day, thanks! That was fun!

Seriously. We don't do homework problems for you. If you have a question about the assignment, ask it, but don't ask us to fix the entire program for you.

Besides, giving someone a deadline on a free help forum is kind of rude, anyways...

True alc6379, common shabna, we dont get paid for doing this, we are in this to help each other.Chainsaw is a jolly good guy, but if someone wants to take things up a bit, you will find yourself being kicked around.

Btw, check your other post, Stack Overflow has given some very good links which I recommend you read and remmember.
http://www.daniweb.com/techtalkforums/thread10188.html

I didn't realize this was a duplicate thread. Thread locked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.