473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Movie list

Hey!
Im working on a movie list, but i donīt get the delete part of it to work.
Help please :p
Many thanks//SoulHack

# include <iostream.h>
# include <conio.h>
# include <string.h>
# include <fstream.h>
# include <stdlib.h>
# include <iomanip.h>
# include <time.h>
#include <vector>

struct film
{

char typ[30];
char titel[30];
};


void meny();
void laggtill(film &b);
void read();
void soka();
void remove();



int main()
{
int svar;


film f;

while(svar!=5)
{
meny();
cin>>svar;
cout<<endl;
cin.ignore(10,'\n');

if (svar==5)
{
system("cls");
cout<<endl<<"**** V\x84lkommen tillbaka n\x84sta g\x86ng! ****"<<endl;
getch();
}
else if (svar==1)
{
ofstream utfil;
utfil.open("filmlista", ios::app);
laggtill(f);
utfil.write((char *)&f, sizeof(film));
utfil.close();
}
else if (svar==2)
{
read();
}
else if (svar==3)
{
soka();
}
else if (svar==4)
{
remove();
}
}

return 0;
}


void meny()
{
{
tm tidstrukt;
long tidsrymd=time(NULL);
tidstrukt=*localtime(&tidsrymd);
cout<<endl;
cout<<"Dagens datum : ";
cout<<setfill('0')<<(tidstrukt.tm_year+1900)<<"-";
cout<<setw(2)<<(tidstrukt.tm_mon+1)<<"-";
cout<<setw(2)<<(tidstrukt.tm_mday)<<"";
cout<<endl;
}
cout<<endl;
cout<<"********* Meny *********"<<endl;
cout<<"* *";
cout<<endl;
cout<<"* ";
cout<<"1. L\x84gg till film"<<" *"<<endl;
cout<<"* ";
cout<<"2. Lista alla filmer"<<" *"<<endl;
cout<<"* ";
cout<<"3. S\x94k titel"<<" *"<<endl;
cout<<"* ";
cout<<"4. Ta bort film "<<" *"<<endl;
cout<<"* ";
cout<<"5. Avsluta "<<" *"<<endl;
cout<<"* *";
cout<<endl;
cout<<"************************"<<endl;
cout<<endl;
cout<<"Ange val : ";

}
void remove()
{

system("cls");
int hittad=0;
ifstream infil;

char svar[40];
film b;
cout<<"Ange filmens titel eller typ : ";
cin.getline(svar,40);

infil.open("filmlista",ios::binary);
while (infil.read((char *)&b, sizeof(film)))
{
if (stricmp(svar, b.titel)==0||(stricmp(svar, b.typ)==0))
{

//How do i do this? If i want to remove
the movie that the program finds?

}
}
{
if(hittad==0)
{
cout<<endl<<"Filmen finns ej!"<<endl;
}
}

}
void laggtill(film& b)
{

cout<<"Ange filmens titel : ";
cin.getline(b.titel, 30);
cout<<"Ange typ av film : ";
cin.getline(b.typ, 30);
system("cls");
}
void read()
{
int i=0;
ifstream infil;
film b;
infil.open("filmlista",ios::binary);
while (infil.read((char *)&b, sizeof(film)))
{
cout<<endl<<++i<<"."<<" "<<b.titel<<" "<<endl<<endl<<" "<<""<<b.typ<<""<<endl<<"________________________" <<endl;
}
infil.close();
getch();

system("cls");
}
void soka()
{
system("cls");
int hittad=0;
ifstream infil;
char svar[40];
film b;
cout<<"Ange filmens titel eller typ : ";
cin.getline(svar,40);

infil.open("filmlista",ios::binary);
while (infil.read((char *)&b, sizeof(film)))
{
if (stricmp(svar, b.titel)==0||(stricmp(svar, b.typ)==0))
{
cout<<endl<<b.titel<<" "<<"["<<b.typ<<"]"<<endl;
hittad=1;
}

}
{
if(hittad==0)
{
cout<<endl<<"Filmen finns ej!"<<endl;
}
}
}
Sep 2 '05 #1
0 1752

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: AES/newspost | last post by:
Can anyone provide a quick tip on the html structure to link from a thumb to a movie poster and from there on to a QuickTime movie, all in one go, using EMBED? I have a number of (large)...
2
by: Niall Linden | last post by:
Is there any way to put text on an avi or movie in a web browser. are there any browser plugins, movie players etc that can facilitate this. i found in flash you can have EMBED mode="transparent"...
6
by: jonathanztaub | last post by:
I have a DVD CD. * Is it possible to embed it within an html page? * Does the user has to have windows media player or any other program associated with it? * How exactly do I use the <embed>...
1
by: torbs | last post by:
I have a problem when I use javascript to get the length and position of a movie I recieve from a rtsp stream. The length and position is extremely high and not the actual length and position of...
1
by: giangiammy | last post by:
hi all, tryng python with pygame, I get the followinf error: faberdanaio.py:28: RuntimeWarning: use movie: No module named movie animation = pygame.movie.Movie("images/film.mpeg") Traceback...
9
by: Audrey | last post by:
Hi, Can I find transitions like on movie maker ? Can I use it on C# program ?
5
by: =?Utf-8?B?V2FsdA==?= | last post by:
Can't import music to movie maker. The tracks show in my music. But when I try to import from my music, under the audio file extension, the folder shows empty. When I click on "all files" the...
5
by: Kaosman | last post by:
I have been trying to figure out this problem for a while. All I want to do is have a combo box populate a list box and the list box change to the record based on the users choice. The combo...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.