//#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct match {
string id;
string team1;
string team2;
string date;
string time;
string league;
};
istream& operator>>(istream &in, match &m) {
getline(in, m.id);
getline(in, m.team1);
getline(in, m.team2);
getline(in, m.date);
getline(in, m.time);
getline(in, m.league);
return in;
}
ostream& operator<<(ostream &out, const match &m) {
out << "the match id: " << m.id << "\n";
out << "teams: " << m.team1 << " vs " << m.team2 << "\n";
out << "time of match: " << m.time << "\n";
out << "date of match: " << m.date << "\n";
out << "league: " << m.league << "\n\n";
return out;
}
void getmatches() {
int i = 0;
const int size = 50;
match matches[size];
ifstream show("matches.txt");
while (i < size && show >> matches[i])
{
cout << matches[i] << endl;
++i;
}
}
int main() {
getmatches();
}
1
Team 1
Team 2
6/2/2021
12:00pm
Youth
2
Team 3
Team 4
6/2/2021
6:00pm
Adult