comp2A2.cpp - #include <fstream>#include <ctime>#include <iostream> using namespace std struct Date int day int month int year char ch\/this struct was

comp2A2.cpp - #include <fstream>#include <ctime>#include...

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

#include <fstream>#include <ctime>#include <iostream>using namespace std;struct Date{int day;int month;int year;char ch;};//this struct was givenDate getCurrentDate(){Date d;time_t theTime = time(NULL);struct tm *aTime = localtime(&theTime);d.day = aTime->tm_mday;d.month = aTime->tm_mon + 1; // Month is 0 - 11, add 1 to get a jan-dec 1-12conceptd.year = aTime->tm_year + 1900;return d;}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 id;string fname;string lname;char gender;int age;string POB;};struct Movie{int code;string name;string genre;Date releasedate;long long gross;double rating;};struct Cast{int mcode;string aid;string role;};
Background image
//write print functions to print the details of each structurevoid printActor(Actor a){cout<<a.id<<" "<<a.fname<<" "<<a.lname<<" "<<a.gender<<" "<<a.age<<" "<<a.POB<<" "<<endl;}void printMovie(Movie m){cout<< m.code<<" "<< m.name<<" "<< m.genre<<" "<<m.releasedate.day<<m.releasedate.ch<<m.releasedate.month<<m.releasedate.ch<<m.releasedate.year<<" "<< m.gross<<" "<< m.rating<< endl;}void printCast(Cast c){cout<<c.mcode<<" "<<c.aid<<" "<<c.role<<endl;}int loadActors (Actor actors[]){ifstream fin1;string tfName, tlName;int tage;string tPOB;char tgender;string taid; Actor a;int numActors=0;fin1.open("actors.txt");if(!fin1.is_open()){cout << "File not found." << endl;return 1;}fin1>>taid;while(taid!="END" && numActors<100){fin1>>tfName>>tlName>>tgender>>tage>>tPOB;a.id=taid;a.fname=tfName;a.lname=tlName;a.gender=tgender;a.age=tage;a.POB=tPOB;
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 7 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture