| | |
correct errors in this program
![]() |
•
•
Join Date: Sep 2004
Posts: 1
Reputation:
Solved Threads: 0
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
PROGRAM
#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();
}
PROGRAM
#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();
}
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!
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!
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
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
![]() |
Similar Threads
- I can't fix/identify the errors with this program (C++)
- Weird build errors that are not even in my program Please help!! (C++)
- I cant correct these two errors (C++)
Other Threads in the C Forum
- Previous Thread: C programming question
- Next Thread: winding rule in graphics
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft motherboard mqqueue mysql number odf open openwebfoundation owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h






