tester2.cpp - #include <fstream>#include <iostream> using namespace std struct Date int day int month int year char ch Date releasedate ifstream in int

tester2.cpp - #include <fstream>#include <iostream> using...

This preview shows page 1 - 3 out of 5 pages.

#include <fstream> #include <iostream> using namespace std; struct Date{ int day; int month; int year; char ch; }; Date releasedate(){ ifstream in; int day; int year; int month; char ch; in.open("movies.txt"); in>>day; in>>ch; in>>month; in>>ch; in>>year; } struct Actor{ string actId; string fName; string lName; char gender; int age; string pob; }; struct Movie{ int movieId; string movieName; string genre; Date releasedate; long long Wwgross; double starRating; }; struct Cast{ int movieId; string actId; string role; }; //write print functions to print the details of each structure void printActor(Actor a){ cout<<a.actId<<" " <<a.fName<<" " <<a.lName<<" " <<a.gender<<" " <<a.age<<" " <<a.pob<<" "<<endl; } void printMovie(Movie m){ cout<<m.movieId<<" " <<m.movieName<<" " <<m.genre<<" " <<m.releasedate.day<<
Image of page 1
m.releasedate.ch<< m.releasedate.month<< m.releasedate.ch<< m.releasedate.year<<" " <<m.Wwgross<<" " <<m.starRating<<endl; } void printCast(Cast c){ cout<<c.movieId<<" " <<c.actId<<" " <<c.role<<endl; } //This function reads the data from the file actors.txt and creates Actor structures and inserts them in an array of Actor structures. //The function accepts the array of Actor structures and returns the number of elements in the array. int loadActors(Actor actors[]){ ifstream in; in.open("actors.txt"); //check to see if file is found string aId; Actor a; int numActors=0; in>>aId; while(aId!="END"){ a.actId=aId; in>>a.fName>>a.lName>>a.gender>>a.age>>a.pob; actors[numActors]=a; numActors=numActors+1; in>>aId; } return numActors; } //This function reads the data from the file movies.txt and creates Movie structures and inserts them in an array of Movie structures.
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 5 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes