Movie records with arrays program help!

Make a movie_record struct, and then make an array of movie_record structs.
(How?????????????????)

After I setup your array of movie records, then write a function, set_movies(), that allows you to set the information for each movie, i.e. the title, rating, description, copies, and genre. You only have to do this for 5 movies, i.e. #define NUM_MOVIES 5.

Now, write another function, which_movies_to_view(), that asks the user which
movies he/she wants to view. You can ask the user if he/she want to see all movies or by genre, and write a function, get_movies(), to display the titles of movies depending on the user’s choice. Hint: This might be a good time to use function overloading

Lastly, let the user choose to see more information about a movie or rent a movie. Write a function, get_movie_info(), that displays all the information about a specific movie for a user, and write another function, rent_movie(), that rents the movie to the user by decrementing the number of copies for a specific movie.

I have this so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
  #include<iostream>
  #include<string>
  #include<cstring>
 
  #define NUM_MOVIES 5
 
  using namespace std;
 
  struct movie_record
  {
     string title;
     int copies;
     string rating;
     string description;
     string genre;
  };
 
 
  void set_movies();
  void which_movies_to_view();
  void get_movies();
  void get_movie_info();
  void rent_movie();
 
 
  int main()
  {
 
 
 
  }


Can someone help me? not fully understanding how to get full sentences for arrays and use the struct. Please help.
Creating an array of struct is as straight forward as creating an array.

Create your movie_record as an array!
1
2
3
4
5
6
int main()
{
    movie_record myMovieList[ NUM_MOVIES ];

    return 0;
}
Okay, so now I have to make 5 movies in this array.

"The bourne identity"
"The bourne legacy"
"Tangled"
"Tron"
"Die Hard"

Now I have to make them strings correct?
something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
  
   movie_record myMoviesList[NUM_MOVIES];
 
     string.myMoviesList[0]="die hard";
     string.myMoviesList[1]="the bourne identity";
     string.myMoviesList[2]="the bourne legacy";
     string.myMoviesList[3]="tron";
     string.myMoviesList[4]="tangled";

return 0;
}


I do get errors but is this in the right direction? What do I need to fix?
To access the data members, use .(dot) notation.

i.e.
myMovieList[ 0 ].title = "Die Hard"; etc.
Okay got that to work.
Now how would I create a function set_movies(), that allows you to set the information for each movie, i.e. the title, rating, description, copies, and genre. You only have to do this for 5 movies, that's why I use #define NUM_MOVIES 5.

Any help?
Topic archived. No new replies allowed.