:)
Hello experts, Im taking a C++ class and i was asked to Write a program that uses a structure named MovieData to store the following information about a movie:
Title
Director
Year Released
Running Time (in minutes)
I've come down to making it compile, but, when it couts the output, the line for "year released" and for "run time" is i think, the reference for those cells. I tried to dereference using the & (i.e &p.year... &p.time) operator and no luck,
it gives me a runtime error, any suggestions?
here is my code:
#include <iostream>
#include <iomanip>
using namespace std;
const int TITLE = 50;
const int RELEASED = 2000;
const int RUN_TIME = 300;
const int NAME_SIZE = 50;
struct movieData
{
char title[TITLE];
char director[NAME_SIZE];
int year[RELEASED];
int time[RUN_TIME];
};
void getInfo(movieData&);
void showInfo(movieData);
int main()
{
movieData movie;
getInfo(movie);
showInfo(movie);
return 0;
}
//Definition of getInfo
void getInfo(movieData &p)
{
//Get movie title
cout << "Enter movie Title:\n";
cin >> p.title;
//Get movie director
cout << "Enter movie's Director:\n";
cin.ignore();
cin.getline(p.director, NAME_SIZE);
//Get year released
cout << "Enter year movie was released:\n";
cin >> p.year[RELEASED];
cout << "Enter the movie's Running Time:\n";
cin >> p.time[RUN_TIME];
}
//Definition of function showInfo
void showInfo(movieData p)
{
cout << fixed << showpoint << setprecision(2);
cout << "Movie Title: " << p.title << endl;
cout << "Director Name: " << p.director << endl;
cout << "Year Released: " << p.year << endl;
cout << "Running Time: " << p.time << endl;
}