Passing Structure-help
Apr 23, 2012 at 3:04am UTC
This toy program is simply supposed to pass a structure to the function and output what was assigned to it in the main()...but I do not know what is wrong, I'm currently getting syntax squigglies under "<<" in function displayMovie. Any help would be greatly appreciated as I am obviously new, thanks!
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 33 34 35 36
struct MovieData
{
string movieTitle;
string director;
int releaseDate;
string movieRuntime;
};
void displayMovie(MovieData m)
{
cout << "Title\t\t: " << m.movieTitle << endl;
cout << "Director\t: " << m.director << endl;
cout << "Released\t: " << m.releaseDate << endl;
cout << "Running Time: " << m.movieRuntime << endl;
}
int main()
{
MovieData movie1;
MovieData movie2;
movie1.movieTitle = "test" ;
movie1.director = "Test" ;
movie1.releaseDate = 2000;
movie1.movieRuntime = "120 minutes" ;
movie2.movieTitle = "TEST" ;
movie2.director = "TEST2" ;
movie2.releaseDate = 2000;
movie2.movieRuntime = "148 minutes" ;
displayMovie(movie1);
displayMovie(movie2);
return 0;
}
Apr 23, 2012 at 6:36am UTC
You need to #include <string>
Apr 23, 2012 at 7:18am UTC
or add .c_ctr(); after writing the strings
Apr 23, 2012 at 12:08pm UTC
simple enough, angry i didn't see that before, thanks!
Topic archived. No new replies allowed.