Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <fstream>
- using namespace std;
- class SAFFFootball {
- private:
- char host_nation[20];
- char year[5];
- char champion[20];
- char runnerup[20];
- char third_place[20];
- char fourth_place[20];
- public:
- SAFFFootball() {}
- ~SAFFFootball() {}
- void read() {
- cout << "Host Nation: ";
- cin >> host_nation;
- cout << "Year: ";
- cin >> year;
- cout << "Champion: ";
- cin >> champion;
- cout << "Runnerup: ";
- cin >> runnerup;
- cout << "Third: ";
- cin >> third_place;
- cout << "Fourth: ";
- cin >> fourth_place;
- }
- char * getHost() { return host_nation; }
- char * getYear() { return year; }
- char * getChampion() { return champion; }
- char * getRunnerup() { return runnerup; }
- char * getThird() { return third_place; }
- char * getFourth() { return fourth_place; }
- };
- int main() {
- char country[20];
- SAFFFootball Rec;
- ifstream infile;
- infile.open("SAFF.dat", ios::binary);
- cout << "Enter team name: ";
- cin >> country;
- cout << "Performance of Bangladesh" << endl;
- while(infile.good()) {
- reinterpret_cast <char *> (&Rec), sizeof(SAFFFootball);
- cout << "Year " << Rec.getYear() << ": ";
- if(!strcmp(country, Rec.getChampion()))
- cout << "Champion" << endl;
- else if(!strcmp(country, Rec.getRunnerup()))
- cout << "Runnerup" << endl;
- else if(!strcmp(country, Rec.getThird()))
- cout << "Third" << endl;
- else if(!strcmp(country, Rec.getFourth()))
- cout << "Fourth" << endl;
- else
- cout << "No information found" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement