Help with file handling

Basically this is a homework assisgnment. So it is a .dat file about football. Their teams, scores etc. Now he wants us to filter and display some things. Would be a comment on what I have to do. Not sure how to go about everything though. Could someone please help me out?

Using C++ by the way.

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
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

//1) Which teams in the NFC conference, East division had winning records? (wins > loses)

//2) Which team scored the most points?

//3) Which team gave up the fewest points?

//4) What was the total number of wins for all of the teams in the league, and what was the total number of loses?

int main() {
	ifstream infile;
	string file = "NFL.dat";
	string city, name, con, div, winteam;
	int win, lose, tie, pos, neg;
	infile.open("NFL.dat");	
	
	if (infile.is_open())
		{ cout << "sucessfully open" << endl;;
		}	
			while ( infile >> city >> name >> con >> div >> win >> lose >> tie >> pos >> neg)
				{ cout << city << setw(7) << name << setw(4) << con << setw(4) << div << setw(4) << win << setw(4) << lose << setw(4) << tie << setw(4) << pos << setw(4) << neg << endl;
				}
			if  (con == "NFC" && div == "EAST")
		{ winteam;
					}			
	infile.close();
	cout << winteam;
	return 0;
}


I was testing it out but doesn't display anything for the winteam. Thought it at least give me the whole thing.
Last edited on
Topic archived. No new replies allowed.