I am writing a program that uses structure named movieData to store the following information about a movie:
Year Released
Running Time (in minutes)
The program should create two movieData variables, store values in their members, and pass each one, in turn, to a function that displays the information about the movie in a clearly formatted manner.

Here is what I have so far. I am not even sure this is correct. Can someone please check this part for me.

include <iostream>
#include <stdlib.h>
using namespace std;
struct Moviedata
         string movieTitle;
         string movieDirector;
         int yearReleased;
         int runningtime;
int main()
  //Get data about a movie.
  cout <<"Enter the following data about a "
  cout << "Title: ";
  cout << "Director: ";
  cin >> Director.name;
  cout << "Year Released: ";
  cin.getline(int yearreleased, Year_size);
  cout << "Running time: ";
  cin.getline(movie.runningtime, Time_size);
      return 0;

Now the second part reads: Modify Movie Data program written for Programming challenge 1 to include two additional members that hold the movie’s production costs and first-year revenues. Modify the function that displays the movie data to display the title, director, release year, running time, and first year’s profit or loss.

This is where I am lost. I have never used C++ before and its kicking my butt. Please help!

7 Years
Discussion Span
Last Post by s_sridhar

Hello Gwen, Welcome to DANIWEB.

Well though I see that your declaration of a struct is quite proper, There is a major fault in your code.

First of , we start by considering what exactly a struct is.
When you use the struct specifier , its almost like you are defining a data-type with already defined data-types.

After defining a struct. you will need to create variables of the type.
This can be done as you declare an int, string etc.

For Example:

struct Example{
//List of members

//Now to declare a variable

//Consider declaring an integer.

int a;
//So in the same way you can declare a Variable of your struct type with::

Example struct1 ;//This declares a variable of type Example and name struct1.

After this is done.
Let's see how to access the members.

struct data{
int a;

//I have defined a type data.

//Now to declare a variable i use,
data var1;

//To access the integer variable 'a' i can now use.


With these examples in mind, Try to assimilate what you have to do,
And the next time Please USE CODE TAGS


I am sorry but I do not know how to use code tags and also is this help with the first part or second?


I am sorry but I do not know how to use code tags

Then you are not paying attention. You had to type right over the instructions when you typed that post. The instructions are also provided when you signed up, and again at the top of every DaniWeb page. Finally, here is yet another set of instructions.

[code=cplusplus] // put your code here



>is this help with the first part or second?

With only the above posted Examples, I think that you can easily complete your program very easily.

However, If I were you and was not understanding what exactly is happening with the code. I would just get back to my TEXT-BOOK and read more.


Here you have not created any structure variables, a structure variable is created as follows, struct moviedata variablename. If you more structure members, include them in the structure definition.

struct moviedata 

Pass the structure variable to the function and display all its members.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.