Hello
I'm a newbie at c++ and I'm doing a basic course in school at the moment. I have an assigment which unfortunately is impossible to complete with my knowledge (that is how it feels like at the moment anyway :'( ) . I'm not looking for someone to do my homework, but I would love to know if I'm on the right track. First let me clearly explain the assignment:

I'm suppose to make an extremely basic registry(I hope this is the right word) for movies. The user is suppose to be able to add movies and what format they are in (eg. VHS DVD HDDVD Bluray). The program have to be able to list all the movies and what format they are in. I have to use this struct:

struct movies
{
char title[50];
char type[10];
};

for these two tasks I've written this(I removed some unecessary stuff to make it easier to look through):

void filminput()
{
movies m;
ofstream utfil;
utfil.open("moviereg",ios::app);
cout << "Title: ";
cin.getline(m.title, 50);
cout << "Type: ";
cin.getline(m.type, 10);
utfil.write((char *)&f, sizeof(filmer));
utfil.close();
}



void filmoutput()
{
movies m;
ifstream infil;
infil.open("moviereg",ios::binary);
while(infil.read((char *)&f, sizeof(filmer)))
{
cout << m.title << m.type << endl;


}
cout << endl;
infil.close();
}

For the two tasks, this proved to work well for me. However there is a third task, which is:
The user should be able to search for a movietitle. If the movie is found, the program shall tell the user which format it is available in. Is it possible to make this happen with the code I have used above? I honestly have no idea if I have to start over with a different approach (I dont have the knowledge of how to tackle this in another way), or what I need to do to make a search function for this task. I don't know much/anything about vectors, or much else in c++.Any tips would really be appreciated, this is depressing the hell out of me! :(

First, your function names seem backwards - typically input means reading from file, output is to write to the file.

That said, to attack your problem you need your file reading function to store to an array of your struct type.

Once stored, in a search function you ask the user to enter a film title, the examine each record in your array, using string comparison to test the title sought against the title member of each array element.

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.